1#ifndef LIBFILEZILLA_EVENT_HANDLER
2#define LIBFILEZILLA_EVENT_HANDLER
87 template<
typename T,
typename...
Args>
89 event_loop_.send_event(
this,
new T(std::forward<Args>(
args)...),
true);
93 void send_event(
T*
evt) {
94 event_loop_.send_event(
this,
evt,
true);
101 event_loop_.send_event(
this,
evt,
false);
174 void resend_current_event() {
175 event_loop_.resend_current_event();
178 event_loop & event_loop_;
180 friend class event_loop;
198template<
typename T,
typename F>
204 std::apply(std::forward<F>(
f),
e->v_);
224template<
typename T,
typename H,
typename F>
230 apply(
h, std::forward<F>(
f),
e->v_);
253template<
typename T,
typename ...
Ts,
typename H,
typename F,
typename ...
Fs>
The duration class represents a time interval in milliseconds.
Definition time.hpp:291
Common base class for all events.
Definition event.hpp:23
Simple handler for asynchronous event processing.
Definition event_handler.hpp:55
timer_id add_timer(duration const &interval, bool one_shot)
Adds a timer, returns the timer id.
void stop_timer(timer_id id)
void remove_handler()
Deactivates handler, removes all pending events and stops all timers for this handler.
timer_id stop_add_timer(timer_id id, duration const &interval, bool one_shot)
virtual void operator()(event_base const &)=0
Called by the event loop in the worker thread with the event to process.
timer_id add_timer(monotonic_clock const &deadline, duration const &interval={})
Adds a timer, returns the timer id.
void send_event(Args &&... args)
Sends the passed event asynchronously to the handler.
Definition event_handler.hpp:88
void send_persistent_event(T *evt)
Be careful with lifetime.
Definition event_handler.hpp:100
timer_id stop_add_timer(timer_id id, monotonic_clock const &deadline, duration const &interval={})
A threaded event loop that supports sending events and timers.
Definition event_loop.hpp:34
A monotonic clock (aka steady clock) is independent from walltime.
Definition time.hpp:403
A simple threaded event loop for the typesafe event system.
The namespace used by libfilezilla.
Definition apply.hpp:17
bool dispatch(event_base const &ev, F &&f)
Dispatch for simple_event<> based events to simple functors.
Definition event_handler.hpp:199
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