shutdown_state.cpp 542 B

1234567891011121314151617181920
  1. #include "shutdown_state.h"
  2. #include <util/system/yassert.h>
  3. void TAtomicShutdownState::ShutdownCommand() {
  4. Y_ABORT_UNLESS(State.CompareAndSet(SS_RUNNING, SS_SHUTDOWN_COMMAND));
  5. }
  6. void TAtomicShutdownState::CompleteShutdown() {
  7. Y_ABORT_UNLESS(State.CompareAndSet(SS_SHUTDOWN_COMMAND, SS_SHUTDOWN_COMPLETE));
  8. ShutdownComplete.Signal();
  9. }
  10. bool TAtomicShutdownState::IsRunning() {
  11. return State.Get() == SS_RUNNING;
  12. }
  13. TAtomicShutdownState::~TAtomicShutdownState() {
  14. Y_ABORT_UNLESS(SS_SHUTDOWN_COMPLETE == State.Get());
  15. }