#include <mono/utils/mono-tls.h>
#include <mono/utils/hazard-pointer.h>
#include <mono/utils/mono-memory-model.h>
-#include <mono/metadata/appdomain.h>
-#include <mono/metadata/domain-internals.h>
#include <errno.h>
THREADS_DEBUG ("unregistering info %p\n", info);
+ mono_threads_core_unregister (info);
+
/*
* TLS destruction order is not reliable so small_id might be cleaned up
* before us.
}
void
-mono_thread_info_dettach (void)
+mono_thread_info_detach (void)
{
MonoThreadInfo *info;
if (!mono_threads_inited)
{
/* This can happen from DllMain(THREAD_DETACH) on Windows, if a thread
* is created before an embedding API user initialized Mono. */
- THREADS_DEBUG ("mono_thread_info_dettach called before mono_threads_init\n");
+ THREADS_DEBUG ("mono_thread_info_detach called before mono_threads_init\n");
return;
}
info = mono_native_tls_get_value (thread_info_key);
gboolean result = TRUE;
MonoThreadHazardPointers *hp = mono_hazard_pointer_get ();
MonoThreadInfo *info = mono_thread_info_lookup (tid); /*info on HP1*/
+
if (!info)
return FALSE;
+ if (info->create_suspended) {
+ /* Have to special case this, as the normal suspend/resume pair are racy, they don't work if he resume is received before the suspend */
+ info->create_suspended = FALSE;
+ mono_threads_core_resume_created (info, tid);
+ return TRUE;
+ }
+
MONO_SEM_WAIT_UNITERRUPTIBLE (&info->suspend_semaphore);
THREADS_DEBUG ("resume %x IN COUNT %d\n",tid, info->suspend_count);
return FALSE;
}
+/*
+ * mono_threads_create_thread:
+ *
+ * Create a new thread executing START with argument ARG. Store its id into OUT_TID.
+ * Returns: a windows or io-layer handle for the thread.
+ */
+HANDLE
+mono_threads_create_thread (LPTHREAD_START_ROUTINE start, gpointer arg, guint32 stack_size, guint32 creation_flags, MonoNativeThreadId *out_tid)
+{
+ return mono_threads_core_create_thread (start, arg, stack_size, creation_flags, out_tid);
+}
+
+/*
+ * mono_thread_info_get_stack_bounds:
+ *
+ * Return the address and size of the current threads stack. Return NULL as the
+ * stack address if the stack address cannot be determined.
+ */
+void
+mono_thread_info_get_stack_bounds (guint8 **staddr, size_t *stsize)
+{
+ return mono_threads_core_get_stack_bounds (staddr, stsize);
+}
+
+gboolean
+mono_thread_info_yield (void)
+{
+ return mono_threads_core_yield ();
+}
+
+gpointer
+mono_thread_info_tls_get (THREAD_INFO_TYPE *info, MonoTlsKey key)
+{
+ return ((MonoThreadInfo*)info)->tls [key];
+}
+
+/*
+ * mono_threads_info_tls_set:
+ *
+ * Set the TLS key to VALUE in the info structure. This can be used to obtain
+ * values of TLS variables for threads other than the current thread.
+ * This should only be used for infrequently changing TLS variables, and it should
+ * be paired with setting the real TLS variable since this provides no GC tracking.
+ */
+void
+mono_thread_info_tls_set (THREAD_INFO_TYPE *info, MonoTlsKey key, gpointer value)
+{
+ ((MonoThreadInfo*)info)->tls [key] = value;
+}
+
+/*
+ * mono_thread_info_exit:
+ *
+ * Exit the current thread.
+ * This function doesn't return.
+ */
+void
+mono_thread_info_exit (void)
+{
+ mono_threads_core_exit (0);
+}
+
+/*
+ * mono_thread_info_open_handle:
+ *
+ * Return a io-layer/win32 handle for the current thread.
+ * The handle need to be closed by calling CloseHandle () when it is no
+ * longer needed.
+ */
+HANDLE
+mono_thread_info_open_handle (void)
+{
+ return mono_threads_core_open_handle ();
+}