1 #ifndef LIBFILEZILLA_EVENT_HANDLER
2 #define LIBFILEZILLA_EVENT_HANDLER
71 void remove_handler();
79 virtual void operator()(
event_base const&) = 0;
87 template<
typename T,
typename... Args>
89 event_loop_.send_event(
this,
new T(std::forward<Args>(args)...));
93 void send_event(T* evt) {
94 event_loop_.send_event(
this, evt);
114 timer_id add_timer(monotonic_clock
const &deadline, duration
const& interval = {});
132 timer_id add_timer(duration
const& interval,
bool one_shot);
138 void stop_timer(timer_id
id);
147 timer_id stop_add_timer(timer_id
id, monotonic_clock
const& deadline, duration
const& interval = {});
156 timer_id stop_add_timer(timer_id
id, duration
const& interval,
bool one_shot);
158 event_loop & event_loop_;
160 friend class event_loop;
178 template<
typename T,
typename F>
181 bool const same = same_type<T>(ev);
183 T
const* e =
static_cast<T const*
>(&ev);
204 template<
typename T,
typename H,
typename F>
207 bool const same = same_type<T>(ev);
209 T
const* e =
static_cast<T const*
>(&ev);
210 apply(h, std::forward<F>(f), e->v_);
233 template<
typename T,
typename ... Ts,
typename H,
typename F,
typename ... Fs>
236 if (dispatch<T>(ev, h, std::forward<F>(f))) {
240 return dispatch<Ts...>(ev, h, std::forward<Fs>(fs)...);
auto apply(Obj &&obj, F &&f, Tuple &&args) -> decltype(apply_(std::forward< Obj >(obj), std::forward< F >(f), std::forward< Tuple >(args), Seq()))
Apply tuple to pointer to member.
Definition: apply.hpp:48
Simple handler for asynchronous event processing.
Definition: event_handler.hpp:54
bool dispatch(event_base const &ev, F &&f)
Dispatch for simple_event<> based events to simple functors.
Definition: event_handler.hpp:179
A simple threaded event loop for the typesafe event system.
A threaded event loop that supports sending events and timers.
Definition: event_loop.hpp:33
The namespace used by libfilezilla.
Definition: apply.hpp:17
Common base class for all events.
Definition: event.hpp:22
void send_event(Args &&...args)
Sends the passed event asynchronously to the handler.
Definition: event_handler.hpp:88