OVR_System.cpp
Go to the documentation of this file.
00001 /************************************************************************************
00002 
00003 Filename    :   OVR_System.cpp
00004 Content     :   General kernel initialization/cleanup, including that
00005                 of the memory allocator.
00006 Created     :   September 19, 2012
00007 Notes       : 
00008 
00009 Copyright   :   Copyright 2012 Oculus VR, Inc. All Rights reserved.
00010 
00011 Use of this software is subject to the terms of the Oculus license
00012 agreement provided at the time of installation or download, or which
00013 otherwise accompanies this software in either electronic or hard copy form.
00014 
00015 ************************************************************************************/
00016 
00017 #include "OVR_System.h"
00018 #include "OVR_Threads.h"
00019 #include "OVR_Timer.h"
00020 
00021 namespace OVR {
00022 
00023 // *****  OVR::System Implementation
00024 
00025 // Initializes System core, installing allocator.
00026 void System::Init(Log* log, Allocator *palloc)
00027 {    
00028     if (!Allocator::GetInstance())
00029     {
00030         Log::SetGlobalLog(log);
00031         Timer::initializeTimerSystem();
00032         Allocator::setInstance(palloc);
00033     }
00034     else
00035     {
00036         OVR_DEBUG_LOG(("System::Init failed - duplicate call."));
00037     }
00038 }
00039 
00040 void System::Destroy()
00041 {    
00042     if (Allocator::GetInstance())
00043     {
00044         // Wait for all threads to finish; this must be done so that memory
00045         // allocator and all destructors finalize correctly.
00046 #ifdef OVR_ENABLE_THREADS
00047         Thread::FinishAllThreads();
00048 #endif
00049 
00050         // Shutdown heap and destroy SysAlloc singleton, if any.
00051         Allocator::GetInstance()->onSystemShutdown();
00052         Allocator::setInstance(0);
00053 
00054         Timer::shutdownTimerSystem();
00055         Log::SetGlobalLog(Log::GetDefaultLog());
00056     }
00057     else
00058     {
00059         OVR_DEBUG_LOG(("System::Destroy failed - System not initialized."));
00060     }
00061 }
00062 
00063 // Returns 'true' if system was properly initialized.
00064 bool System::IsInitialized()
00065 {
00066     return Allocator::GetInstance() != 0;
00067 }
00068 
00069 } // OVR
00070 


oculus_sdk
Author(s):
autogenerated on Fri Aug 28 2015 11:53:11