| 42 | |
| 43 | |
| 44 | void async_function(evutil_socket_t socket, short which, void* arg) |
| 45 | { |
| 46 | event* ev = reinterpret_cast<event*>(arg); |
| 47 | event_free(ev); |
| 48 | |
| 49 | std::queue<lambda::function<void()>> q; |
| 50 | |
| 51 | synchronized (functions_mutex) { |
| 52 | std::swap(q, *functions); |
| 53 | } |
| 54 | |
| 55 | while (!q.empty()) { |
| 56 | q.front()(); |
| 57 | q.pop(); |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | |
| 62 | void run_in_event_loop( |