Lines Matching refs:port

65 	struct event_iocp_port *port = _port;  in loop()  local
66 long ms = port->ms; in loop()
67 HANDLE p = port->port; in loop()
78 EnterCriticalSection(&port->lock); in loop()
79 if (port->shutdown) { in loop()
80 if (--port->n_live_threads == 0) in loop()
81 ReleaseSemaphore(port->shutdownSemaphore, 1, in loop()
83 LeaveCriticalSection(&port->lock); in loop()
86 LeaveCriticalSection(&port->lock); in loop()
94 EnterCriticalSection(&port->lock); in loop()
95 if (--port->n_live_threads == 0) in loop()
96 ReleaseSemaphore(port->shutdownSemaphore, 1, NULL); in loop()
97 LeaveCriticalSection(&port->lock); in loop()
101 event_iocp_port_associate(struct event_iocp_port *port, evutil_socket_t fd, in event_iocp_port_associate() argument
105 h = CreateIoCompletionPort((HANDLE)fd, port->port, key, port->n_threads); in event_iocp_port_associate()
177 struct event_iocp_port *port; in event_iocp_port_launch() local
183 if (!(port = mm_calloc(1, sizeof(struct event_iocp_port)))) in event_iocp_port_launch()
188 port->n_threads = n_cpus * 2; in event_iocp_port_launch()
189 port->threads = mm_calloc(port->n_threads, sizeof(HANDLE)); in event_iocp_port_launch()
190 if (!port->threads) in event_iocp_port_launch()
193 port->port = CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, 0, in event_iocp_port_launch()
195 port->ms = -1; in event_iocp_port_launch()
196 if (!port->port) in event_iocp_port_launch()
199 port->shutdownSemaphore = CreateSemaphore(NULL, 0, 1, NULL); in event_iocp_port_launch()
200 if (!port->shutdownSemaphore) in event_iocp_port_launch()
203 for (i=0; i<port->n_threads; ++i) { in event_iocp_port_launch()
204 ev_uintptr_t th = _beginthread(loop, 0, port); in event_iocp_port_launch()
207 port->threads[i] = (HANDLE)th; in event_iocp_port_launch()
208 ++port->n_live_threads; in event_iocp_port_launch()
211 InitializeCriticalSectionAndSpinCount(&port->lock, 1000); in event_iocp_port_launch()
213 return port; in event_iocp_port_launch()
215 if (port->port) in event_iocp_port_launch()
216 CloseHandle(port->port); in event_iocp_port_launch()
217 if (port->threads) in event_iocp_port_launch()
218 mm_free(port->threads); in event_iocp_port_launch()
219 if (port->shutdownSemaphore) in event_iocp_port_launch()
220 CloseHandle(port->shutdownSemaphore); in event_iocp_port_launch()
221 mm_free(port); in event_iocp_port_launch()
226 _event_iocp_port_unlock_and_free(struct event_iocp_port *port) in _event_iocp_port_unlock_and_free() argument
228 DeleteCriticalSection(&port->lock); in _event_iocp_port_unlock_and_free()
229 CloseHandle(port->port); in _event_iocp_port_unlock_and_free()
230 CloseHandle(port->shutdownSemaphore); in _event_iocp_port_unlock_and_free()
231 mm_free(port->threads); in _event_iocp_port_unlock_and_free()
232 mm_free(port); in _event_iocp_port_unlock_and_free()
236 event_iocp_notify_all(struct event_iocp_port *port) in event_iocp_notify_all() argument
239 for (i=0; i<port->n_threads; ++i) { in event_iocp_notify_all()
240 r = PostQueuedCompletionStatus(port->port, 0, NOTIFICATION_KEY, in event_iocp_notify_all()
249 event_iocp_shutdown(struct event_iocp_port *port, long waitMsec) in event_iocp_shutdown() argument
254 EnterCriticalSection(&port->lock); in event_iocp_shutdown()
255 port->shutdown = 1; in event_iocp_shutdown()
256 LeaveCriticalSection(&port->lock); in event_iocp_shutdown()
257 event_iocp_notify_all(port); in event_iocp_shutdown()
262 WaitForSingleObject(port->shutdownSemaphore, ms); in event_iocp_shutdown()
263 EnterCriticalSection(&port->lock); in event_iocp_shutdown()
264 n = port->n_live_threads; in event_iocp_shutdown()
265 LeaveCriticalSection(&port->lock); in event_iocp_shutdown()
267 _event_iocp_port_unlock_and_free(port); in event_iocp_shutdown()
276 struct event_iocp_port *port, struct event_overlapped *o, in event_iocp_activate_overlapped() argument
281 r = PostQueuedCompletionStatus(port->port, n, key, &o->overlapped); in event_iocp_activate_overlapped()