30 extern struct ev_loop**
loops;
39 extern std::queue<lambda::function<void()>>*
functions;
54 explicit LoopIndex(
size_t index) : index(index) {}
69 const lambda::function<
Future<T>(
struct ev_loop*)>&
f,
73 if (
promise->future().hasDiscard()) {
85 const lambda::function<
Future<T>(
struct ev_loop*)>&
f)
87 struct ev_loop* loop = loops[loop_index.
index];
91 if (_in_event_loop_ == loop) {
101 std::lock_guard<std::mutex> guard(functions_mutexes[loop_index.
index]);
102 functions[loop_index.
index].push(
107 ev_async_send(loop, &async_watchers[loop_index.
index]);
114 #endif // __LIBEV_HPP__
F && f
Definition: defer.hpp:270
ev_async * async_watchers
std::queue< lambda::function< void()> > * functions
size_t index
Definition: libev.hpp:51
Future< T > run_in_event_loop(const LoopIndex loop_index, const lambda::function< Future< T >(struct ev_loop *)> &f)
Definition: libev.hpp:83
Definition: future.hpp:74
Protocol< PromiseRequest, PromiseResponse > promise
Future< V > loop(const Option< UPID > &pid, Iterate &&iterate, Body &&body)
Definition: loop.hpp:456
thread_local struct ev_loop * _in_event_loop_
Definition: libevent.hpp:28
Definition: executor.hpp:48
friend LoopIndex get_loop(int_fd fd)
Try< Nothing > bind(int_fd s, const Address &address)
Definition: network.hpp:46
void _run_in_event_loop(struct ev_loop *loop, const lambda::function< Future< T >(struct ev_loop *)> &f, const Owned< Promise< T >> &promise)
Definition: libev.hpp:67
int int_fd
Definition: int_fd.hpp:35
std::mutex * functions_mutexes
Definition: future.hpp:58