JAVA_BOOLEAN org_xmlvm_runtime_FinalizerNotifier_shouldInvokeFinalizers__()
{
    //XMLVM_BEGIN_NATIVE[org_xmlvm_runtime_FinalizerNotifier_shouldInvokeFinalizers__]
#ifndef XMLVM_NO_GC
    return GC_should_invoke_finalizers();
#else
    return 0;
#endif
    //XMLVM_END_NATIVE
}
예제 #2
0
int ILGCInvokeFinalizers(int timeout)
{
	int retval = 0;
	
	if (GC_should_invoke_finalizers())
	{
		retval = PrivateGCNotifyFinalize(timeout, 0);
	}
	
	return retval;
}
예제 #3
0
파일: boehm-gc.c 프로젝트: Sciumo/mono
int
mono_gc_invoke_finalizers (void)
{
	/* There is a bug in GC_invoke_finalizer () in versions <= 6.2alpha4:
	 * the 'mem_freed' variable is not initialized when there are no
	 * objects to finalize, which leads to strange behavior later on.
	 * The check is necessary to work around that bug.
	 */
	if (GC_should_invoke_finalizers ())
		return GC_invoke_finalizers ();
	return 0;
}
예제 #4
0
/*
 *	Main entry point for the finalizer thread.
 */
static void _FinalizerThreadFunc(void *data)
{
	GC_TRACE("GC:_FinalizerThread: Finalizer thread started [thread:%d]\n", (int)ILThreadSelf());

	for (;;)
	{
		ILWaitOne(_FinalizerSignal, -1);

		GC_TRACE("GC:_FinalizerThread: Signal [thread:%d]\n", (int)ILThreadSelf());

		/* This *must* to be set before checking for !_FinalizersDisabled to prevent
		    a race with ILGCDisableFinalizers */

		_FinalizersRunning = 1;

		ILThreadMemoryBarrier();

		if (GC_should_invoke_finalizers() && !_FinalizersDisabled)
		{
			GC_TRACE("GC:_FinalizerThread: Finalizers running [thread:%d]\n", (int)ILThreadSelf());
			
			GC_invoke_finalizers();
			
			GC_TRACE("GC:_FinalizerThread: Finalizers finished [thread:%d]\n", (int)ILThreadSelf());
		}

		_FinalizersRunning = 0;

		ILThreadMemoryBarrier();
		
		if (_FinalizerStopFlag)
		{
			/* Exit finalizer thread after having invoked finalizers one last time */

			GC_TRACE("GC:_FinalizerThread: Finalizer thread finished [thread:%d]\n", (int)ILThreadSelf());

			ILWaitEventReset(_FinalizerSignal);
			/* Wake all waiting threads */
			ILWaitEventPulse(_FinalizerResponse);
			
			return;
		}

		GC_TRACE("GC:_FinalizerThread: Response [thread:%d]\n", (int)ILThreadSelf());

		ILWaitEventReset(_FinalizerSignal);

		/* Wake all waiting threads */
		ILWaitEventPulse(_FinalizerResponse);
	}
}
예제 #5
0
void boehm_gc_finalizer_notifier(void)
{
    boehm_gc_finalizer_lock++;
    while (GC_should_invoke_finalizers()) {
        if (boehm_gc_finalizer_lock > 1) {
            /* GC_invoke_finalizers() will be done by the
               boehm_gc_finalizer_notifier() that is
               currently in the C stack, when we return there */
            break;
        }
        GC_invoke_finalizers();
    }
    boehm_gc_finalizer_lock--;
}
예제 #6
0
/*
 * Tries to invoke finalizers synchronously.
 * Returns 0 if successful or -1 if it would be unsafe to do so.
 */
static int _InvokeFinalizersSynchronously()
{
	unsigned long fg, bg;

	ILThreadGetCounts(&fg, &bg);

	if (!GC_should_invoke_finalizers())
	{
		return 0;
	}
	
	/* Prevent recursive finalization */
	if (_FinalizersRunningSynchronously)
	{
		return 0;
	}

	if (fg + bg > 1)
	{
		/* Threads are supported and there are other threads active so it isn't
		   safe to invoke finalizers synchronously. */

		return -1;
	}
	else
	{
		/* Because there is only one thread active (this thread), it is safe to
		   invoke finalizers synchronously */

		_FinalizersRunning = 1;
		_FinalizersRunningSynchronously = 1;

		GC_invoke_finalizers();

		_FinalizersRunning = 0;
		_FinalizersRunningSynchronously = 0;

		return 0;
	}
}
예제 #7
0
파일: boehm-gc.c 프로젝트: Sciumo/mono
gboolean
mono_gc_pending_finalizers (void)
{
	return GC_should_invoke_finalizers ();
}