Skip to content

Commit

Permalink
added an explanation for State class
Browse files Browse the repository at this point in the history
  • Loading branch information
defiantnerd committed Sep 11, 2023
1 parent c1618da commit 4f2ad8e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/detail/vst3/os/osutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<void()> on, std::function<void()> off) : _on(on), _off(off)
{
Expand Down

0 comments on commit 4f2ad8e

Please sign in to comment.