/** * @file include/di/Semaphore.h * @brief Counting semaphore implementation * @date March 31, 2016 * @author R.W.A. van der Heijden * @copyright 2016 Dual Inventive Technology Centre B.V. * * Counting semaphore implementation using C++ STL */ #ifndef INCLUDE_DI_SEMAPHORE_H_ #define INCLUDE_DI_SEMAPHORE_H_ #include #include #include namespace Di { /** * @class Semaphore * * Counting semaphore implementation using C++ STL */ class Semaphore { public: /** * Constructor, initialized the counter */ Semaphore(); /** * Notify the waiting process */ void notify(void); /** * Wait for a notification */ void wait(void); private: std::mutex __mutex; //!< Mutex used for condition std::condition_variable __condition; //!< Condition for waiting uint64_t __count; //!< Semaphore counter }; } // namespace Di #endif // INCLUDE_DI_SEMAPHORE_H_