#pragma once #include "public.h" #ifndef _linux_ #include #include #endif namespace NYT::NThreading { //////////////////////////////////////////////////////////////////////////////// //! A synchronization aid that allows one or more threads to wait until //! a set of operations being performed in other threads completes. /*! * See https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/CountDownLatch.html */ class TCountDownLatch final { public: explicit TCountDownLatch(int count); void CountDown(); void Wait() const; bool TryWait() const; int GetCount() const; private: std::atomic Count_; #ifndef _linux_ mutable TCondVar ConditionVariable_; mutable TMutex Mutex_; #endif }; //////////////////////////////////////////////////////////////////////////////// } // namespace NYT::NThreading