21 #ifndef INCLUDE_OLA_IO_SELECTSERVER_H_
22 #define INCLUDE_OLA_IO_SELECTSERVER_H_
25 #include <ola/Clock.h>
27 #include <ola/io/Descriptor.h>
28 #include <ola/io/SelectServerInterface.h>
29 #include <ola/network/Socket.h>
30 #include <ola/thread/Thread.h>
36 class SelectServerTest;
48 enum Direction {READ, WRITE};
54 bool IsRunning()
const {
return !m_terminate; }
59 void SetDefaultInterval(
const TimeInterval &poll_interval);
61 void RunOnce(
unsigned int delay_sec = POLL_INTERVAL_SECOND,
62 unsigned int delay_usec = POLL_INTERVAL_USECOND);
66 bool delete_on_close =
false);
73 ola::thread::timeout_id RegisterRepeatingTimeout(
76 ola::thread::timeout_id RegisterRepeatingTimeout(
80 ola::thread::timeout_id RegisterSingleTimeout(
83 ola::thread::timeout_id RegisterSingleTimeout(
86 void RemoveTimeout(ola::thread::timeout_id
id);
93 typedef std::set<ola::Callback0<void>*> LoopClosureSet;
96 bool m_terminate, m_is_running;
98 std::auto_ptr<class TimeoutManager> m_timeout_manager;
99 std::auto_ptr<class PollerInterface> m_poller;
103 LoopClosureSet m_loop_closures;
104 std::queue<ola::BaseCallback0<void>*> m_incoming_queue;
109 void DrainAndExecute();
110 void SetTerminate() { m_terminate =
true; }
113 static const unsigned int POLL_INTERVAL_SECOND = 10;
114 static const unsigned int POLL_INTERVAL_USECOND = 0;
118 friend class ::SelectServerTest;
124 #endif // INCLUDE_OLA_IO_SELECTSERVER_H_