1 #ifndef ERIS_EVENT_SERVICE_H 2 #define ERIS_EVENT_SERVICE_H 4 #include <sigc++/signal.h> 6 #include <boost/asio/io_service.hpp> 7 #include <boost/asio/steady_timer.hpp> 8 #include <boost/noncopyable.hpp> 26 TimedEvent(
EventService& eventService,
const std::chrono::steady_clock::duration& duration,
const std::function<
void()>& callback);
30 std::unique_ptr<boost::asio::steady_timer> m_timer;
50 explicit EventService(boost::asio::io_service& io_service);
66 void runOnMainThread(
const std::function<
void()>& handler,
67 std::shared_ptr<bool> activeMarker = std::make_shared<bool>(
true));
76 void runOnMainThreadDelayed(
const std::function<
void()>& handler,
77 const std::chrono::steady_clock::duration& duration,
78 std::shared_ptr<bool> activeMarker = std::make_shared<bool>(
true));
87 size_t processAllHandlers();
96 size_t processOneHandler();
101 boost::asio::io_service& m_io_service;
102 std::unique_ptr<boost::asio::io_service::work> m_work;
108 std::deque<std::function<void()>> m_handlers;
116 std::unique_ptr<WaitFreeQueue<std::function<void()>>> m_background_handlers_queue;
122 std::unique_ptr<boost::asio::steady_timer> createTimer();
127 size_t collectHandlersQueue();
134 #endif // of ERIS_EVENT_SERVICE_H Class for things which occur after a period of time.
Handles polling of the IO system as well as making sure that registered handlers are run on the main ...
A queue optimized for insertion from background threads and consumption from one main thread...