All Classes Namespaces Functions Variables Typedefs Enumerations Friends
callback_notifier.h
1 
5 #include <atomic>
6 #include <condition_variable>
7 #include <mutex>
8 namespace ucxx {
9 
10 namespace utils {
11 
19  private:
20  std::atomic_bool _flag{}; //< flag storing state
21  std::mutex _mutex{}; //< lock to guard accesses
22  std::condition_variable _conditionVariable{}; //< notification condition var
23 
24  public:
39  CallbackNotifier() : _flag{false} {};
40 
41  ~CallbackNotifier() = default;
42 
43  CallbackNotifier(const CallbackNotifier&) = delete;
44  CallbackNotifier& operator=(CallbackNotifier const&) = delete;
45  CallbackNotifier(CallbackNotifier&& o) = delete;
46  CallbackNotifier& operator=(CallbackNotifier&& o) = delete;
47 
54  void set();
55 
74  bool wait(uint64_t period = 0,
75  std::function<void(void)> signalWorkerFunction = nullptr,
76  uint64_t signalRerun = 100000000);
77 };
78 
79 } // namespace utils
80 } // namespace ucxx
Definition: callback_notifier.h:18
bool wait(uint64_t period=0, std::function< void(void)> signalWorkerFunction=nullptr, uint64_t signalRerun=100000000)
Wait until set() has been called or period has elapsed.
void set()
Notify waiting threads that we are done and they can proceed.
CallbackNotifier()
Construct a thread-safe notification object.
Definition: callback_notifier.h:39
Definition: address.h:15