Skip to content

Commit

Permalink
change Reset() to expect Shutdown state
Browse files Browse the repository at this point in the history
  • Loading branch information
kpschoedel committed Oct 20, 2021
1 parent 8ae9322 commit 78535d5
Showing 1 changed file with 1 addition and 18 deletions.
19 changes: 1 addition & 18 deletions src/lib/support/ObjectLifeCycle.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,24 +74,7 @@ class ObjectLifeCycle
bool SetInitialized() { return Transition<State::Initializing, State::Initialized>(); }
bool SetShuttingDown() { return Transition<State::Initialized, State::ShuttingDown>(); }
bool SetShutdown() { return Transition<State::ShuttingDown, State::Shutdown>(); }

/**
* Transition from Shutdown back to Uninitialized, or remain Uninitialized.
*
* Typical use is `VerifyOrReturnError(state.Reset(), CHIP_ERROR_INCORRECT_STATE)`; this function returns `bool` rather than
* a `CHIP_ERROR` so that error source tracking will record the call point rather than this function itself.
*
* @return true if the state was Uninitialized or Shutdown and is now Uninitialized.
* @return false otherwise.
*/
bool Reset()
{
if (mState == State::Shutdown)
{
mState = State::Uninitialized;
}
return mState == State::Uninitialized;
}
bool Reset() { return Transition<State::Shutdown, State::Uninitialized>(); }

/**
* Transition from Uninitialized or Shutdown to Destroyed.
Expand Down

0 comments on commit 78535d5

Please sign in to comment.