1#ifndef LIBFILEZILLA_INVOKER_HEADER
2#define LIBFILEZILLA_INVOKER_HEADER
13struct invoker_event_type{};
16typedef simple_event<invoker_event_type, std::function<
void()>> invoker_event;
22 thread_invoker(event_loop&
loop);
23 virtual ~thread_invoker();
25 virtual void operator()(event_base
const&
ev)
override;
29template<
typename...
Args>
30std::function<
void(
Args...)> do_make_invoker(event_loop&
loop, std::function<
void(
Args...)> &&
f)
33 auto cb = [
f,
targs = std::make_tuple(std::forward<Args>(
args)...)] {
36 handler.send_event<invoker_event>(std::move(
cb));
43template<
typename Ret,
typename F,
typename ...
Args>
56 return do_make_invoker(
loop,
decltype(get_func_type(&F::operator()))(std::forward<F>(
f)));
61 return do_make_invoker(
h.event_loop_,
decltype(get_func_type(&F::operator()))(std::forward<F>(
f)));
65typedef std::function<
void(std::function<
void()>)> invoker_factory;
76template<
typename...
Args>
77std::function<
void(
Args...)> do_make_invoker(invoker_factory
const&
inv, std::function<
void(
Args...)> &&
f)
80 auto cb = [
f,
targs = std::make_tuple(std::forward<Args>(
args)...)] {
97 return do_make_invoker(
inv,
decltype(get_func_type(&F::operator()))(std::forward<F>(
f)));
A threaded event loop that supports sending events and timers.
Definition event_loop.hpp:34
Declares the event_handler class.
The namespace used by libfilezilla.
Definition apply.hpp:17
invoker_factory get_invoker_factory(event_loop &loop)
Creates an invoker factory.
bool dispatch(event_base const &ev, F &&f)
Dispatch for simple_event<> based events to simple functors.
Definition event_handler.hpp:199
auto make_invoker(event_loop &loop, F &&f)
Wraps the passed function, so that it is always invoked in the context of the loop.
Definition invoker.hpp:54