gint32 limit_io_min;
gint32 limit_io_max;
-
- MonoThreadPoolWorker *worker;
} ThreadPool;
static mono_lazy_init_t status = MONO_LAZY_INIT_STATUS_NOT_INITIALIZED;
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 (&threadpool.worker);
+ mono_threadpool_worker_init ();
}
static void
mono_coop_mutex_unlock (&threadpool.threads_lock);
#endif
- mono_threadpool_worker_cleanup (threadpool.worker);
+ mono_threadpool_worker_cleanup ();
mono_refcount_dec (&threadpool);
}
mono_threadpool_suspend (void)
{
if (mono_lazy_is_initialized (&status))
- mono_threadpool_worker_set_suspended (threadpool.worker, TRUE);
+ mono_threadpool_worker_set_suspended (TRUE);
}
void
mono_threadpool_resume (void)
{
if (mono_lazy_is_initialized (&status))
- mono_threadpool_worker_set_suspended (threadpool.worker, FALSE);
+ mono_threadpool_worker_set_suspended (FALSE);
}
void
counter = COUNTER_READ ();
- *worker_threads = MAX (0, mono_threadpool_worker_get_max (threadpool.worker) - counter._.working);
+ *worker_threads = MAX (0, mono_threadpool_worker_get_max () - counter._.working);
*completion_port_threads = threadpool.limit_io_max;
}
mono_lazy_initialize (&status, initialize);
- *worker_threads = mono_threadpool_worker_get_min (threadpool.worker);
+ *worker_threads = mono_threadpool_worker_get_min ();
*completion_port_threads = threadpool.limit_io_min;
}
mono_lazy_initialize (&status, initialize);
- *worker_threads = mono_threadpool_worker_get_max (threadpool.worker);
+ *worker_threads = mono_threadpool_worker_get_max ();
*completion_port_threads = threadpool.limit_io_max;
}
if (completion_port_threads <= 0 || completion_port_threads > threadpool.limit_io_max)
return FALSE;
- if (!mono_threadpool_worker_set_min (threadpool.worker, worker_threads))
+ if (!mono_threadpool_worker_set_min (worker_threads))
return FALSE;
threadpool.limit_io_min = completion_port_threads;
if (completion_port_threads < threadpool.limit_io_min || completion_port_threads < cpu_count)
return FALSE;
- if (!mono_threadpool_worker_set_max (threadpool.worker, worker_threads))
+ if (!mono_threadpool_worker_set_max (worker_threads))
return FALSE;
threadpool.limit_io_max = completion_port_threads;
if (mono_domain_is_unloading (mono_domain_get ()) || mono_runtime_is_shutting_down ())
return FALSE;
- return mono_threadpool_worker_notify_completed (threadpool.worker);
+ return mono_threadpool_worker_notify_completed ();
}
void
ves_icall_System_Threading_ThreadPool_NotifyWorkItemProgressNative (void)
{
- mono_threadpool_worker_notify_completed (threadpool.worker);
+ mono_threadpool_worker_notify_completed ();
}
void
counter._.starting ++;
});
- mono_threadpool_worker_enqueue (threadpool.worker, worker_callback, NULL);
+ mono_threadpool_worker_enqueue (worker_callback, NULL);
+
+ /* we do not decrement the threadpool refcount,
+ * as it's going to be done in the worker_callback */
return TRUE;
}