BeeeOn Gateway  v2020.3.1-2-g6f737dc
Platform to interconnect the IoT world
Joiner.h
1 #pragma once
2 
3 #include <Poco/Thread.h>
4 #include <Poco/Timespan.h>
5 
6 namespace BeeeOn {
7 
21 class Joiner {
22 public:
23  Joiner(Poco::Thread &thread);
24 
32  void join(const Poco::Timespan &timeout = -1);
33 
41  bool tryJoin(const Poco::Timespan &timeout = -1);
42 
43 protected:
48  void joinFromMany(long ms);
49 
53  void doJoin(long ms);
54 
55 private:
56  Poco::Thread &m_thread;
57  Poco::FastMutex m_joinLock;
58  bool m_joined;
59 };
60 
61 }
void join(const Poco::Timespan &timeout=-1)
Join the underlying thread. The timeout controls whether we are waiting indefinitely (when negative) ...
Definition: Joiner.cpp:26
void doJoin(long ms)
Call the actual join based on the timeout.
Definition: Joiner.cpp:69
Joiner implements join() on a thread that can be called multiple times from different threads...
Definition: Joiner.h:21
void joinFromMany(long ms)
Implement locking to allow exactly 1 thread to call the join(). The lock respects the given timeout...
Definition: Joiner.cpp:55
bool tryJoin(const Poco::Timespan &timeout=-1)
Join the underlying thread. The timeout controls whether we are waiting indefinitely (when negative) ...
Definition: Joiner.cpp:31