Panda3D
 All Classes Functions Variables Enumerations
dtoolbase.cxx
00001 // Filename: dtoolbase.cxx
00002 // Created by:  drose (12Sep00)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #include "dtoolbase.h"
00016 #include "memoryHook.h"
00017 
00018 #if defined(USE_TAU) && defined(WIN32)
00019 // Hack around tau's lack of DLL export declarations for Profiler class.
00020 bool __tau_shutdown = false;
00021 #endif
00022 
00023 MemoryHook *memory_hook;
00024 
00025 ////////////////////////////////////////////////////////////////////
00026 //     Function: init_memory_hook
00027 //  Description: Any code that might need to use PANDA_MALLOC or
00028 //               PANDA_FREE, or any methods of the global memory_hook
00029 //               object, at static init time, should ensure that it
00030 //               calls init_memory_hook() first to ensure that the
00031 //               pointer has been properly initialized.  There is no
00032 //               harm in calling this function more than once.
00033 //
00034 //               There is no need to call this function other than at
00035 //               static init time.
00036 ////////////////////////////////////////////////////////////////////
00037 void
00038 init_memory_hook() {
00039   if (memory_hook == NULL) {
00040     memory_hook = new MemoryHook;
00041   }
00042 }
00043 
00044 // Here's a quick way to ensure the above function is called at least
00045 // once at static init time.
00046 class InitMemoryHook {
00047 public:
00048   InitMemoryHook() {
00049     init_memory_hook();
00050   }
00051 };
00052 static InitMemoryHook _imh_object;
00053 
00054 #if defined(HAVE_THREADS) && defined(SIMPLE_THREADS)
00055 
00056 static void
00057 default_thread_yield() {
00058 }
00059 static void
00060 default_thread_consider_yield() {
00061 }
00062 void (*global_thread_yield)() = default_thread_yield;
00063 void (*global_thread_consider_yield)() = default_thread_consider_yield;
00064 
00065 #endif  // HAVE_THREADS && SIMPLE_THREADS
 All Classes Functions Variables Enumerations