BeeeOn Gateway  v2020.3.1-2-g6f737dc
Platform to interconnect the IoT world
ThreadRecursionProtector.h
1 #pragma once
2 
3 #include <Poco/ThreadLocal.h>
4 
5 namespace BeeeOn {
6 
15 public:
21  class Guard {
22  public:
23  Guard(
24  ThreadRecursionProtector &protector,
25  const char *file = 0,
26  int line = 0);
27  ~Guard();
28 
29  private:
30  ThreadRecursionProtector &m_protector;
31  };
32 
34 
39  void enter(const char *file = 0, int line = 0);
40 
46  void leave();
47 
48 private:
49  Poco::ThreadLocal<bool> m_protect;
50 };
51 
52 }
Guard calls ThreadRecursionProtector::enter() from constructor and ThreadRecursionProtector::leave() ...
Definition: ThreadRecursionProtector.h:21
ThreadRecursionProtector allows to prevent a recursive or repetitive execution of a code...
Definition: ThreadRecursionProtector.h:14
void enter(const char *file=0, int line=0)
Mark location where the recursion is possible. If the enter is called again, it would fail...
Definition: ThreadRecursionProtector.cpp:16
void leave()
Leave location where the recursion was possible. Now, the ThreadRecursionProtector::enter() would not...
Definition: ThreadRecursionProtector.cpp:29