X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Fmetadata%2Fthreadpool.c;h=9a9e7a4cb345ac73cd88bce8d3ed4a273fd8d461;hb=ce6acbe4db3caca1d54f08f9758a88a7768ff236;hp=e8a2f1a45741b3248d33e1a1ed238c1d91c81d17;hpb=4df4b7a47a07d924d7bfcfc53f43bd2319b54266;p=mono.git diff --git a/mono/metadata/threadpool.c b/mono/metadata/threadpool.c index e8a2f1a4574..9a9e7a4cb34 100644 --- a/mono/metadata/threadpool.c +++ b/mono/metadata/threadpool.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #ifdef HAVE_SYS_TIME_H #include @@ -158,6 +159,7 @@ static MonoClass *process_async_call_klass; static GPtrArray *wsqs; CRITICAL_SECTION wsqs_lock; +static gboolean suspended; /* Hooks */ static MonoThreadPoolFunc tp_start_func; @@ -777,6 +779,9 @@ monitor_thread (gpointer unused) if (mono_runtime_is_shutting_down ()) break; + if (suspended) + continue; + for (i = 0; i < 2; i++) { ThreadPool *tp; tp = pools [i]; @@ -1675,3 +1680,21 @@ mono_internal_thread_unhandled_exception (MonoObject* exc) mono_thread_internal_reset_abort (mono_thread_internal_current ()); } } + +/* + * Suspend creation of new threads. + */ +void +mono_thread_pool_suspend (void) +{ + suspended = TRUE; +} + +/* + * Resume creation of new threads. + */ +void +mono_thread_pool_resume (void) +{ + suspended = FALSE; +}