#include <mono/utils/mono-threads.h>
#include <mono/utils/mono-lazy-init.h>
#include <mono/utils/mono-logger-internals.h>
+#include <mono/utils/w32api.h>
typedef struct {
gboolean (*init) (gint wakeup_pipe_fd);
}
}
+static void
+selector_thread_interrupt (gpointer unused)
+{
+ selector_thread_wakeup ();
+}
+
static gsize WINAPI
selector_thread (gpointer data)
{
states = mono_g_hash_table_new_type (g_direct_hash, g_direct_equal, MONO_HASH_VALUE_GC, MONO_ROOT_SOURCE_THREAD_POOL, "i/o thread pool states table");
- for (;;) {
+ while (!mono_runtime_is_shutting_down ()) {
gint i, j;
gint res;
+ gboolean interrupted = FALSE;
+
+ if (mono_thread_interruption_checkpoint ())
+ continue;
mono_coop_mutex_lock (&threadpool_io->updates_lock);
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_THREADPOOL, "io threadpool: wai");
- res = threadpool_io->backend.event_wait (wait_callback, states);
+ mono_thread_info_install_interrupt (selector_thread_interrupt, NULL, &interrupted);
+ if (interrupted)
+ continue;
- if (res == -1 || mono_runtime_is_shutting_down ())
+ res = threadpool_io->backend.event_wait (wait_callback, states);
+ if (res == -1)
break;
+
+ mono_thread_info_uninstall_interrupt (&interrupted);
}
mono_g_hash_table_destroy (states);
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)
- mono_thread_info_usleep (1000);
+ // FIXME destroy everything
}
void