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);
67 std::shared_ptr<bool> activeMarker = std::make_shared<bool>(
true));
77 const std::chrono::steady_clock::duration& duration,
78 std::shared_ptr<bool> activeMarker = std::make_shared<bool>(
true));
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();
Handles polling of the IO system as well as making sure that registered handlers are run on the main ...
size_t processAllHandlers()
Processes all registered handlers.
size_t processOneHandler()
Processes one handler, if possible.
void runOnMainThreadDelayed(const std::function< void()> &handler, const std::chrono::steady_clock::duration &duration, std::shared_ptr< bool > activeMarker=std::make_shared< bool >(true))
EventService(boost::asio::io_service &io_service)
Ctor.
void runOnMainThread(const std::function< void()> &handler, std::shared_ptr< bool > activeMarker=std::make_shared< bool >(true))
Adds a handler which will be run on the main thread.
Class for things which occur after a period of time.
A queue optimized for insertion from background threads and consumption from one main thread.