session_job_count.cpp 460 B

12345678910111213141516171819202122
  1. #include "session_job_count.h"
  2. #include <util/system/yassert.h>
  3. using namespace NBus;
  4. using namespace NBus::NPrivate;
  5. TBusSessionJobCount::TBusSessionJobCount()
  6. : JobCount(0)
  7. {
  8. }
  9. TBusSessionJobCount::~TBusSessionJobCount() {
  10. Y_ABORT_UNLESS(JobCount == 0, "must be 0 job count to destroy job");
  11. }
  12. void TBusSessionJobCount::WaitForZero() {
  13. TGuard<TMutex> guard(Mutex);
  14. while (AtomicGet(JobCount) > 0) {
  15. CondVar.WaitI(Mutex);
  16. }
  17. }