diff --git a/src/detail/vst3/os/osutil.h b/src/detail/vst3/os/osutil.h index 76ffc1f1..b45f11f1 100644 --- a/src/detail/vst3/os/osutil.h +++ b/src/detail/vst3/os/osutil.h @@ -14,9 +14,17 @@ namespace os { - + class State { + // the State class ensures that a specific function pair (like init/terminate) is only called in pairs. + // the bool _state reflects if the _on lambda has already been called + // on destruction, it makes sure that the _off lambda is definitely called. + // + // the construct should only be applied to when no state machine can cover this properly + // or your own code depends on correct calling sequences of an external code base and should + // help to implement defensive programming. + public: State(std::function on, std::function off) : _on(on), _off(off) {