#include "EventUtils.hh" #include #include #include #include #include static void dispatch_forward_to_event_thread(evutil_socket_t, short, void* ctx) { auto* fn = reinterpret_cast*>(ctx); (*fn)(); delete fn; } void forward_to_event_thread(std::shared_ptr base, std::function&& fn) { struct timeval tv = {0, 0}; std::function* new_fn = new std::function(std::move(fn)); event_base_once(base.get(), -1, EV_TIMEOUT, dispatch_forward_to_event_thread, new_fn, &tv); }