Example #1
0
static void
cleanup (void)
{
	/* we make the assumption along the code that we are
	 * cleaning up only if the runtime is shutting down */
	g_assert (mono_runtime_is_shutting_down ());

	selector_thread_wakeup ();
	while (io_selector_running)
		g_usleep (1000);

	mono_mutex_destroy (&threadpool_io->updates_lock);
	mono_cond_destroy (&threadpool_io->updates_cond);

	threadpool_io->backend.cleanup ();

#if !defined(HOST_WIN32)
	close (threadpool_io->wakeup_pipes [0]);
	close (threadpool_io->wakeup_pipes [1]);
#else
	closesocket (threadpool_io->wakeup_pipes [0]);
	closesocket (threadpool_io->wakeup_pipes [1]);
#endif

	g_assert (threadpool_io);
	g_free (threadpool_io);
	threadpool_io = NULL;
	g_assert (!threadpool_io);
}
Example #2
0
static void
worker_park (void)
{
	mono_cond_t cond;
	mono_cond_init (&cond, NULL);

	mono_mutex_lock (&threadpool->parked_threads_lock);
	g_ptr_array_add (threadpool->parked_threads, &cond);
	mono_cond_wait (&cond, &threadpool->parked_threads_lock);
	g_ptr_array_remove (threadpool->parked_threads, &cond);
	mono_mutex_unlock (&threadpool->parked_threads_lock);

	mono_cond_destroy (&cond);
}