summaryrefslogtreecommitdiff
path: root/event_iocp.c
diff options
context:
space:
mode:
authorChristopher Davis <chrisd@torproject.org>2010-08-28 04:07:48 -0700
committerChristopher Davis <chrisd@torproject.org>2010-09-08 01:22:22 -0700
commit2447fe88860c40e968261ad8ea059166cb84a280 (patch)
tree35c57c9b079c34137fb2677856f7d59cea85f317 /event_iocp.c
parent499452f4c24f172bf6846599e3886838a4207aca (diff)
downloadlibevent-2447fe88860c40e968261ad8ea059166cb84a280.tar.gz
Add event_config_set_num_cpus_hint for tuning thread pools, etc.
Diffstat (limited to 'event_iocp.c')
-rw-r--r--event_iocp.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/event_iocp.c b/event_iocp.c
index 19c7bffc..254ed90d 100644
--- a/event_iocp.c
+++ b/event_iocp.c
@@ -162,8 +162,10 @@ event_get_win32_extension_fns(void)
return &the_extension_fns;
}
+#define N_CPUS_DEFAULT 2
+
struct event_iocp_port *
-event_iocp_port_launch(void)
+event_iocp_port_launch(int n_cpus)
{
struct event_iocp_port *port;
int i;
@@ -173,12 +175,16 @@ event_iocp_port_launch(void)
if (!(port = mm_calloc(1, sizeof(struct event_iocp_port))))
return NULL;
- port->n_threads = 2;
+
+ if (n_cpus <= 0)
+ n_cpus = N_CPUS_DEFAULT;
+ port->n_threads = n_cpus * 2;
port->threads = calloc(port->n_threads, sizeof(HANDLE));
if (!port->threads)
goto err;
- port->port = CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, 0, port->n_threads);
+ port->port = CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, 0,
+ n_cpus);
port->ms = -1;
if (!port->port)
goto err;