BeeeOn Gateway  v2020.3.1-2-g6f737dc
Platform to interconnect the IoT world
StoppableLoop.h
1 #pragma once
2 
3 #include <Poco/SharedPtr.h>
4 #include <Poco/Timespan.h>
5 
6 #include "util/Loggable.h"
7 #include "loop/StoppableRunnable.h"
8 
9 namespace Poco {
10 
11 class Thread;
12 
13 }
14 
15 namespace BeeeOn {
16 
18 public:
19  typedef Poco::SharedPtr<StoppableLoop> Ptr;
20 
21  virtual ~StoppableLoop();
22 
26  virtual void start() = 0;
27 
31  virtual void stop() = 0;
32 };
33 
35  public Loggable,
36  public StoppableLoop {
37 public:
38  StoppableLoopAdapter(StoppableRunnable::Ptr runnable);
40 
41  void start() override;
42  void stop() override;
43 
44  void setStopTimeout(const Poco::Timespan &timeout);
45 
46  StoppableRunnable::Ptr runnable() const;
47 
48 protected:
49  void doStop();
50 
51 private:
52  Poco::Timespan m_stopTimeout;
53  StoppableRunnable::Ptr m_runnable;
54  Poco::Thread *m_thread;
55 };
56 
57 }
Definition: StoppableLoop.h:17
void stop() override
Definition: StoppableLoop.cpp:55
virtual void stop()=0
virtual void start()=0
void start() override
Definition: StoppableLoop.cpp:43
Definition: Loggable.h:19
Definition: StoppableLoop.h:34