libfilezilla
Loading...
Searching...
No Matches
wxinvoker.hpp
Go to the documentation of this file.
1#ifndef LIBFILEZILLA_GLUE_WXINVOKER_HEADER
2#define LIBFILEZILLA_GLUE_WXINVOKER_HEADER
3
8#include "../invoker.hpp"
9
10#include <wx/event.h>
11
12namespace fz {
13
15template<typename... Args>
16std::function<void(Args...)> do_make_invoker(wxEvtHandler& handler, std::function<void(Args...)> && f)
17{
18 return [&handler, cf = f](Args&&... args) mutable {
19 auto cb = [cf, targs = std::make_tuple(std::forward<Args>(args)...)] {
20 std::apply(cf, targs);
21 };
22 handler.CallAfter(cb);
23 };
24}
25
27template<typename F>
28auto make_invoker(wxEvtHandler& handler, F && f)
29{
30 return do_make_invoker(handler, decltype(get_func_type(&F::operator()))(std::forward<F>(f)));
31}
32
34inline invoker_factory get_invoker_factory(wxEvtHandler& handler)
35{
36 return [&handler](std::function<void()> const& cb) mutable {
37 handler.CallAfter(cb);
38 };
39}
40
41}
42
43#endif
The namespace used by libfilezilla.
Definition apply.hpp:17
invoker_factory get_invoker_factory(event_loop &loop)
Creates an invoker factory.
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