![]() |
libfilezilla
|


Public Member Functions | |
| event_handler (event_loop &loop) | |
| event_handler (event_handler const &h) | |
| event_handler (event_handler &h, event_handler_option opt) | |
| event_handler & | operator= (event_handler const &)=delete |
| void | remove_handler () |
| Deactivates handler, removes all pending events and stops all timers for this handler. | |
| virtual void | operator() (event_base const &)=0 |
| Called by the event loop in the worker thread with the event to process. | |
| template<typename T, typename... Args> | |
| void | send_event (Args &&... args) |
| Sends the passed event asynchronously to the handler. | |
| template<typename T> | |
| void | send_event (T *evt) |
| template<typename T> | |
| void | send_persistent_event (T *evt) |
| Be careful with lifetime. | |
| timer_id | add_timer (monotonic_clock const &deadline, duration const &interval={}) |
| Adds a timer, returns the timer id. | |
| timer_id | add_timer (duration const &interval, bool one_shot) |
| Adds a timer, returns the timer id. | |
| void | stop_timer (timer_id id) |
| timer_id | stop_add_timer (timer_id id, monotonic_clock const &deadline, duration const &interval={}) |
| timer_id | stop_add_timer (timer_id id, duration const &interval, bool one_shot) |
| void | filter_events (std::function< bool(event_base &ev)> const &filter) |
| void | resend_current_event () |
| void | remove_events (event_source const *const source) |
| template<typename T> | |
| void | remove_events () |
Public Attributes | |
| event_loop & | event_loop_ |
Friends | |
| class | event_loop |
| timer_id add_timer | ( | duration const & | interval, |
| bool | one_shot ) |
Adds a timer, returns the timer id.
Once the interval expires, you get a timer event from the event loop.
One-shot timers are deleted automatically
For periodic timers, the next event is scheduled right before the callback is called. If multiple intervals expire before the timer fires, e.g. under heavy load, only one event is sent.
If multiple different timers have expired, the order in which the callbacks are executed is unspecified, but they will get provessed eventually, high-frequency timers with slow handlers cannot completely starve other timers.
Timers and other queued events are interleaved.
| timer_id add_timer | ( | monotonic_clock const & | deadline, |
| duration const & | interval = {} ) |
Adds a timer, returns the timer id.
Once the deadline is reached, you get a timer event from the event loop. If the deadline is empty, no timer is actually added and the returned timer id is 0.
If the interval is empty, timers are deleted automatically, otherwise the interval is the period of the timer after the deadline is reached.
For periodic timers, the next event is scheduled right before the callback is called. If multiple intervals expire before the timer fires, e.g. under heavy load, only one event is sent.
If multiple different timers have expired, the order in which the callbacks are executed is unspecified, but they will get provessed eventually, high-frequency timers with slow handlers cannot completely starve other timers.
Timers and other queued events are interleaved.
|
pure virtual |
Called by the event loop in the worker thread with the event to process.
Override in your derived class.
Consider using dispatch inside your function.
Implemented in reader_base.
| void remove_handler | ( | ) |
Deactivates handler, removes all pending events and stops all timers for this handler.
remove_handler implicitly removes all nested child event handlers as well.
When this function returns, neither handler nor nested child event handlers are in their callback anymore, with the exception being handlers that self-remove inside their own or nested child handler callbacks.
|
inline |
This must only be called inside the handler's operator()(event_base const&), calling it at other times or different threads is undefined behaviour. Must not be called with timer events.
|
inline |
Sends the passed event asynchronously to the handler.
Can be called from any thread.
All events are processed in the order they are sent, excluding possible races between threads.
| timer_id stop_add_timer | ( | timer_id | id, |
| duration const & | interval, | ||
| bool | one_shot ) |
Stops the given timer, then adds a new one. Returns the timer id of the newly added timer.
It behaves as-if the two following calls were made in sequence:
stop_timer(id); return add_timer(interval, one_shot);
| timer_id stop_add_timer | ( | timer_id | id, |
| monotonic_clock const & | deadline, | ||
| duration const & | interval = {} ) |
Stops the given timer, then adds a new one. Returns the timer id of the newly added timer.
It behaves as-if the two following calls were made in sequence:
stop_timer(id); return add_timer(deadline, interval);
| void stop_timer | ( | timer_id | id | ) |
Stops the given timer.
One-shot timers that have fired stop automatically and do not need to be stopped.