Lines Matching refs:reactor
55 reactor_t* reactor; // the reactor instance this object is registered with. member
64 static reactor_status_t run_reactor(reactor_t* reactor, int iterations);
114 void reactor_free(reactor_t* reactor) { in reactor_free() argument
115 if (!reactor) return; in reactor_free()
117 list_free(reactor->invalidation_list); in reactor_free()
118 close(reactor->event_fd); in reactor_free()
119 close(reactor->epoll_fd); in reactor_free()
120 osi_free(reactor); in reactor_free()
123 reactor_status_t reactor_start(reactor_t* reactor) { in reactor_start() argument
124 CHECK(reactor != NULL); in reactor_start()
125 return run_reactor(reactor, 0); in reactor_start()
128 reactor_status_t reactor_run_once(reactor_t* reactor) { in reactor_run_once() argument
129 CHECK(reactor != NULL); in reactor_run_once()
130 return run_reactor(reactor, 1); in reactor_run_once()
133 void reactor_stop(reactor_t* reactor) { in reactor_stop() argument
134 CHECK(reactor != NULL); in reactor_stop()
136 eventfd_write(reactor->event_fd, EVENT_REACTOR_STOP); in reactor_stop()
139 reactor_object_t* reactor_register(reactor_t* reactor, int fd, void* context, in reactor_register() argument
142 CHECK(reactor != NULL); in reactor_register()
148 object->reactor = reactor; in reactor_register()
161 if (epoll_ctl(reactor->epoll_fd, EPOLL_CTL_ADD, fd, &event) == -1) { in reactor_register()
183 if (epoll_ctl(object->reactor->epoll_fd, EPOLL_CTL_MOD, object->fd, &event) == in reactor_change_registration()
200 reactor_t* reactor = obj->reactor; in reactor_unregister() local
202 if (epoll_ctl(reactor->epoll_fd, EPOLL_CTL_DEL, obj->fd, NULL) == -1) in reactor_unregister()
206 if (reactor->is_running && in reactor_unregister()
207 pthread_equal(pthread_self(), reactor->run_thread)) { in reactor_unregister()
208 reactor->object_removed = true; in reactor_unregister()
213 std::unique_lock<std::mutex> lock(*reactor->list_mutex); in reactor_unregister()
214 list_append(reactor->invalidation_list, obj); in reactor_unregister()
234 static reactor_status_t run_reactor(reactor_t* reactor, int iterations) { in run_reactor() argument
235 CHECK(reactor != NULL); in run_reactor()
237 reactor->run_thread = pthread_self(); in run_reactor()
238 reactor->is_running = true; in run_reactor()
243 std::lock_guard<std::mutex> lock(*reactor->list_mutex); in run_reactor()
244 list_clear(reactor->invalidation_list); in run_reactor()
248 OSI_NO_INTR(ret = epoll_wait(reactor->epoll_fd, events, MAX_EVENTS, -1)); in run_reactor()
252 reactor->is_running = false; in run_reactor()
262 eventfd_read(reactor->event_fd, &value); in run_reactor()
263 reactor->is_running = false; in run_reactor()
269 std::unique_lock<std::mutex> lock(*reactor->list_mutex); in run_reactor()
270 if (list_contains(reactor->invalidation_list, object)) { in run_reactor()
279 reactor->object_removed = false; in run_reactor()
283 if (!reactor->object_removed && events[j].events & EPOLLOUT && in run_reactor()
288 if (reactor->object_removed) { in run_reactor()
295 reactor->is_running = false; in run_reactor()