[threadpool] Pass callback at initialization (#4546)
[mono.git] / mono / metadata / threadpool.c
index 0b36a37cee925f982d5d36686cbfecfb4e31e881..3c0fa3d7f6db0ebda4cd140ae42d6f7a7b60e716 100644 (file)
@@ -1,5 +1,6 @@
-/*
- * threadpool.c: Microsoft threadpool runtime support
+/**
+ * \file
+ * Microsoft threadpool runtime support
  *
  * Author:
  *     Ludovic Henry (ludovic.henry@xamarin.com)
@@ -121,6 +122,9 @@ destroy (gpointer unused)
        mono_coop_mutex_destroy (&threadpool.domains_lock);
 }
 
+static void
+worker_callback (void);
+
 static void
 initialize (void)
 {
@@ -134,7 +138,7 @@ initialize (void)
        threadpool.limit_io_min = mono_cpu_count ();
        threadpool.limit_io_max = CLAMP (threadpool.limit_io_min * 100, MIN (threadpool.limit_io_min, 200), MAX (threadpool.limit_io_min, 200));
 
-       mono_threadpool_worker_init ();
+       mono_threadpool_worker_init (worker_callback);
 }
 
 static void
@@ -276,7 +280,7 @@ try_invoke_perform_wait_callback (MonoObject** exc, MonoError *error)
 }
 
 static void
-worker_callback (gpointer unused)
+worker_callback (void)
 {
        MonoError error;
        ThreadPoolDomain *tpdomain, *previous_tpdomain;
@@ -778,7 +782,7 @@ ves_icall_System_Threading_ThreadPool_RequestWorkerThread (void)
                counter._.starting ++;
        });
 
-       mono_threadpool_worker_enqueue (worker_callback, NULL);
+       mono_threadpool_worker_request ();
 
        mono_refcount_dec (&threadpool);
        return TRUE;