Skip to content

Commit

Permalink
Mon Oct 6 16:10:02 CEST 2008 Paolo Molaro <lupus@ximian.com>
Browse files Browse the repository at this point in the history
	* gc.c, attach.h, attach.c: remove a bad pattern:
	add_finalizer_callback () is not implemented correctly, it can't
	without adding more overhead to the finalizer loop and it's not
	even needed, since we know exactly what we need to call, so there is
	no need to do so through an expensive function pointer.


svn path=/trunk/mono/; revision=114944
  • Loading branch information
illupus committed Oct 6, 2008
1 parent fb8e108 commit 542d5b7
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 33 deletions.
9 changes: 9 additions & 0 deletions mono/metadata/ChangeLog
@@ -1,3 +1,12 @@

Mon Oct 6 16:10:02 CEST 2008 Paolo Molaro <lupus@ximian.com>

* gc.c, attach.h, attach.c: remove a bad pattern:
add_finalizer_callback () is not implemented correctly, it can't
without adding more overhead to the finalizer loop and it's not
even needed, since we know exactly what we need to call, so there is
no need to do so through an expensive function pointer.

2008-10-04 Zoltan Varga <vargaz@gmail.com> 2008-10-04 Zoltan Varga <vargaz@gmail.com>


* gc.c: Define a dummy version of mono_gc_add_finalizer_thread_callback () * gc.c: Define a dummy version of mono_gc_add_finalizer_thread_callback ()
Expand Down
13 changes: 7 additions & 6 deletions mono/metadata/attach.c
Expand Up @@ -108,8 +108,6 @@ static guint32 WINAPI receiver_thread (void *arg);


static void transport_start_receive (void); static void transport_start_receive (void);


static void maybe_start (gpointer user_data);

/* /*
* Functions to decode protocol data * Functions to decode protocol data
*/ */
Expand Down Expand Up @@ -197,8 +195,6 @@ void
mono_attach_init (void) mono_attach_init (void)
{ {
InitializeCriticalSection (&agent_mutex); InitializeCriticalSection (&agent_mutex);

mono_gc_add_finalizer_thread_callback (maybe_start, NULL);
} }


/** /**
Expand Down Expand Up @@ -249,8 +245,8 @@ mono_attach_start (void)
} }


/* Called by the finalizer thread when it is woken up */ /* Called by the finalizer thread when it is woken up */
static void void
maybe_start (gpointer user_data) mono_attach_maybe_start (void)
{ {
if (!needs_to_start) if (!needs_to_start)
return; return;
Expand Down Expand Up @@ -592,6 +588,11 @@ mono_attach_start (void)
return FALSE; return FALSE;
} }


void
mono_attach_maybe_start (void)
{
}

void void
mono_attach_cleanup (void) mono_attach_cleanup (void)
{ {
Expand Down
3 changes: 3 additions & 0 deletions mono/metadata/attach.h
Expand Up @@ -12,6 +12,9 @@ mono_attach_init (void) MONO_INTERNAL;
gboolean gboolean
mono_attach_start (void) MONO_INTERNAL; mono_attach_start (void) MONO_INTERNAL;


void
mono_attach_maybe_start (void) MONO_INTERNAL;

void void
mono_attach_cleanup (void) MONO_INTERNAL; mono_attach_cleanup (void) MONO_INTERNAL;


Expand Down
31 changes: 4 additions & 27 deletions mono/metadata/gc.c
Expand Up @@ -23,6 +23,7 @@
#include <mono/utils/mono-logger.h> #include <mono/utils/mono-logger.h>
#include <mono/metadata/gc-internal.h> #include <mono/metadata/gc-internal.h>
#include <mono/metadata/marshal.h> /* for mono_delegate_free_ftnptr () */ #include <mono/metadata/marshal.h> /* for mono_delegate_free_ftnptr () */
#include <mono/metadata/attach.h>


#ifndef PLATFORM_WIN32 #ifndef PLATFORM_WIN32
#include <pthread.h> #include <pthread.h>
Expand Down Expand Up @@ -53,9 +54,6 @@ static MonoMList *threads_to_finalize = NULL;


static MonoThread *gc_thread; static MonoThread *gc_thread;


static FinalizerThreadCallback fin_thread_cb;
static gpointer fin_thread_cb_user_data;

static void object_register_finalizer (MonoObject *obj, void (*callback)(void *, void*)); static void object_register_finalizer (MonoObject *obj, void (*callback)(void *, void*));


#ifndef HAVE_NULL_GC #ifndef HAVE_NULL_GC
Expand Down Expand Up @@ -838,23 +836,6 @@ mono_gc_finalize_notify (void)
SetEvent (finalizer_event); SetEvent (finalizer_event);
} }


/*
* mono_gc_add_finalizer_thread_callback:
*
* Register a callback function which will be called by the finalizer thread
* each time it is woken up. This means the callback should execute quickly, and
* not block.
*
*/
void
mono_gc_add_finalizer_thread_callback (FinalizerThreadCallback func, gpointer user_data)
{
g_assert (!fin_thread_cb);

fin_thread_cb = func;
fin_thread_cb_user_data = user_data;
}

static void static void
collect_objects (gpointer key, gpointer value, gpointer user_data) collect_objects (gpointer key, gpointer value, gpointer user_data)
{ {
Expand Down Expand Up @@ -929,8 +910,9 @@ finalizer_thread (gpointer unused)
/* Use alertable=FALSE since we will be asked to exit using the event too */ /* Use alertable=FALSE since we will be asked to exit using the event too */
WaitForSingleObjectEx (finalizer_event, INFINITE, FALSE); WaitForSingleObjectEx (finalizer_event, INFINITE, FALSE);


if (fin_thread_cb) #ifndef DISABLE_ATTACH
fin_thread_cb (fin_thread_cb_user_data); mono_attach_maybe_start ();
#endif


if (domains_to_finalize) { if (domains_to_finalize) {
mono_finalizer_lock (); mono_finalizer_lock ();
Expand Down Expand Up @@ -1062,11 +1044,6 @@ mono_gc_finalize_notify (void)
{ {
} }


void
mono_gc_add_finalizer_thread_callback (FinalizerThreadCallback func, gpointer user_data)
{
}

void mono_gc_init (void) void mono_gc_init (void)
{ {
InitializeCriticalSection (&handle_section); InitializeCriticalSection (&handle_section);
Expand Down

0 comments on commit 542d5b7

Please sign in to comment.