summaryrefslogtreecommitdiff
path: root/iocp-internal.h
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2009-04-30 19:04:44 +0000
committerNick Mathewson <nickm@torproject.org>2009-04-30 19:04:44 +0000
commitf1090833b2557bc18353aee293a61ee556da80df (patch)
tree8a4d303f054060e6b7085f067310446060f1368f /iocp-internal.h
parentb45cead762ca0d9b59a71d9a97fe95ce9a4639c3 (diff)
downloadlibevent-f1090833b2557bc18353aee293a61ee556da80df.tar.gz
First tests for IOCP loop, and related fixes.
The fixes are: a shutdown mode that works, and a way to activate an arbitrary event_overlapped. svn:r1254
Diffstat (limited to 'iocp-internal.h')
-rw-r--r--iocp-internal.h33
1 files changed, 28 insertions, 5 deletions
diff --git a/iocp-internal.h b/iocp-internal.h
index c374f612..de731155 100644
--- a/iocp-internal.h
+++ b/iocp-internal.h
@@ -60,13 +60,26 @@ struct event_overlapped {
struct event_iocp_port {
/** The port itself */
HANDLE port;
- /** Number of threads open on the port. */
- int n_threads;
+ /* A lock to cover internal structures. */
+ CRITICAL_SECTION lock;
+ /** Number of threads ever open on the port. */
+ short n_threads;
/** True iff we're shutting down all the threads on this port */
- int shutdown;
+ short shutdown;
/** How often the threads on this port check for shutdown and other
* conditions */
long ms;
+ /* The threads that are waiting for events. */
+ HANDLE *threads;
+ /** Number of threads currently open on this port. */
+ short n_live_threads;
+ /* A semaphore to signal when we are done shutting down. */
+ HANDLE *shutdownSemaphore;
+};
+#else
+/* Dummy definition so we can test-compile more things on unix. */
+struct event_overlapped {
+ iocp_callback cb;
};
#endif
@@ -120,8 +133,18 @@ struct event_iocp_port *event_iocp_port_launch(void);
int event_iocp_port_associate(struct event_iocp_port *port, evutil_socket_t fd,
uintptr_t key);
-/** Shut down all threads serving an iocp. */
-void event_iocp_shutdown(struct event_iocp_port *port);
+/** Tell all threads serving an iocp to stop. Wait for up to waitMsec for all
+ the threads to finish whatever they're doing. If all the threads are
+ done, free the port and return 0. Otherwise, return -1. If you get a -1
+ return value, it is safe to call this function again.
+*/
+int event_iocp_shutdown(struct event_iocp_port *port, long waitMsec);
+
+/* FIXME document. */
+int event_iocp_activate_overlapped(struct event_iocp_port *port,
+ struct event_overlapped *o,
+ uintptr_t key, ev_uint32_t n_bytes);
+
#ifdef __cplusplus
}