#include <mono/metadata/attach.h>
#include <mono/utils/mono-semaphore.h>
-#ifndef PLATFORM_WIN32
+#ifndef HOST_WIN32
#include <pthread.h>
#endif
static GSList *domains_to_finalize= NULL;
static MonoMList *threads_to_finalize = NULL;
-static MonoThread *gc_thread;
+static MonoInternalThread *gc_thread;
static void object_register_finalizer (MonoObject *obj, void (*callback)(void *, void*));
#endif
static void
-add_thread_to_finalize (MonoThread *thread)
+add_thread_to_finalize (MonoInternalThread *thread)
{
mono_finalizer_lock ();
if (!threads_to_finalize)
/* make sure the finalizer is not called again if the object is resurrected */
object_register_finalizer (obj, NULL);
- if (o->vtable->klass == mono_get_thread_class ()) {
- MonoThread *t = (MonoThread*)o;
+ if (o->vtable->klass == mono_defaults.internal_thread_class) {
+ MonoInternalThread *t = (MonoInternalThread*)o;
- if (mono_gc_is_finalizer_thread (t))
+ if (mono_gc_is_finalizer_internal_thread (t))
/* Avoid finalizing ourselves */
return;
mono_gc_finalize_threadpool_threads (void)
{
while (threads_to_finalize) {
- MonoThread *thread = (MonoThread*) mono_mlist_get_data (threads_to_finalize);
+ MonoInternalThread *thread = (MonoInternalThread*) mono_mlist_get_data (threads_to_finalize);
/* Force finalization of the thread. */
thread->threadpool_thread = FALSE;
guint32 res;
HANDLE done_event;
- if (mono_thread_current () == gc_thread)
+ if (mono_thread_internal_current () == gc_thread)
/* We are called from inside a finalizer, not much we can do here */
return FALSE;
if (!mono_gc_pending_finalizers ())
return;
- if (mono_thread_current () == gc_thread)
+ if (mono_thread_internal_current () == gc_thread)
/* Avoid deadlocks */
return;
if (!gc_disabled) {
ResetEvent (shutdown_event);
finished = TRUE;
- if (mono_thread_current () != gc_thread) {
+ if (mono_thread_internal_current () != gc_thread) {
mono_gc_finalize_notify ();
/* Finishing the finalizer thread, so wait a little bit... */
/* MS seems to wait for about 2 seconds */
suspend_finalizers = TRUE;
/* Try to abort the thread, in the hope that it is running managed code */
- mono_thread_stop (gc_thread);
+ mono_thread_internal_stop (gc_thread);
/* Wait for it to stop */
ret = WaitForSingleObjectEx (gc_thread->handle, 100, TRUE);
#endif
+gboolean
+mono_gc_is_finalizer_internal_thread (MonoInternalThread *thread)
+{
+ return thread == gc_thread;
+}
+
/**
* mono_gc_is_finalizer_thread:
* @thread: the thread to test.
gboolean
mono_gc_is_finalizer_thread (MonoThread *thread)
{
- return thread == gc_thread;
+ return mono_gc_is_finalizer_internal_thread (thread->internal_thread);
}