예제 #1
0
void System::Destroy()
{
    GetSSILock().DoLock();
    ShuttingDown = true;
    GetSSILock().Unlock();

    if (--System_Init_Count == 0)
    {
        Logger.LogInfo("Graceful shutdown: OnThreadDestroy");

        // Invoke all of the post-finish callbacks (normal case)
        for (SystemSingletonInternal *listener = SystemShutdownListenerList; listener; listener = listener->NextShutdownSingleton)
        {
            listener->OnThreadDestroy();
        }

        Logger.LogInfo("Graceful shutdown: OnSystemDestroy");

        // Invoke all of the post-finish callbacks (normal case)
        for (SystemSingletonInternal* next, *listener = SystemShutdownListenerList; listener; listener = next)
        {
            next = listener->NextShutdownSingleton;

            listener->OnSystemDestroy();
        }

        SystemShutdownListenerList = nullptr;

        Timer::shutdownTimerSystem();
    }
    else
    {
        Logger.LogDebug("Destroy recursively called; depth = ", System_Init_Count);
    }

    GetSSILock().DoLock();
    ShuttingDown = false;
    GetSSILock().Unlock();

    Logger.LogInfo("Graceful shutdown: Stopping logger");

    // Prevent memory leak reports
    ovrlog::ShutdownLogging();
}
예제 #2
0
void System::Destroy()
{    
    if (Allocator::GetInstance())
    {
#ifdef OVR_OS_WIN32
		Win32::DisplayShim::GetInstance().Shutdown();
#endif

		// Invoke all of the post-finish callbacks (normal case)
        for (SystemSingletonInternal *listener = SystemShutdownListenerStack; listener; listener = listener->NextSingleton)
		{
			listener->OnThreadDestroy();
		}

#ifdef OVR_ENABLE_THREADS
		// Wait for all threads to finish; this must be done so that memory
		// allocator and all destructors finalize correctly.
		Thread::FinishAllThreads();
#endif

		// Invoke all of the post-finish callbacks (normal case)
        for (SystemSingletonInternal *next, *listener = SystemShutdownListenerStack; listener; listener = next)
		{
            next = listener->NextSingleton;

			listener->OnSystemDestroy();
		}

        SystemShutdownListenerStack = 0;

		// Shutdown heap and destroy SysAlloc singleton, if any.
        Allocator::GetInstance()->onSystemShutdown();
        Allocator::setInstance(0);

        Timer::shutdownTimerSystem();
        Log::SetGlobalLog(Log::GetDefaultLog());
    }
    else
    {
        OVR_DEBUG_LOG(("System::Destroy failed - System not initialized."));
    }
}