Panda3D
|
00001 // Filename: config_pipeline.cxx 00002 // Created by: drose (28Mar06) 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 "config_pipeline.h" 00016 #include "asyncTaskBase.h" 00017 #include "mainThread.h" 00018 #include "externalThread.h" 00019 #include "thread.h" 00020 #include "pythonThread.h" 00021 #include "pandaSystem.h" 00022 00023 #include "dconfig.h" 00024 00025 ConfigureDef(config_pipeline); 00026 NotifyCategoryDef(pipeline, ""); 00027 NotifyCategoryDef(thread, ""); 00028 00029 ConfigureFn(config_pipeline) { 00030 init_libpipeline(); 00031 } 00032 00033 ConfigVariableBool support_threads 00034 ("support-threads", true, 00035 PRC_DESC("Set this false to disallow the creation of threads using Panda's " 00036 "Thread interface, even if threading support is compiled in. This " 00037 "does not affect the operation of mutexes and other synchronization " 00038 "primitives, just the creation of threads.")); 00039 00040 ConfigVariableBool name_deleted_mutexes 00041 ("name-deleted-mutexes", false, 00042 PRC_DESC("Set this true to allocate a name to each Mutex object that " 00043 "destructs, so if the Mutex is locked after destruction, we can " 00044 "print out its name to aid debugging. This is only available " 00045 "when compiled with DEBUG_THREADS. Enabling this variable will " 00046 "cause a memory leak, so you should only enable it when you are " 00047 "specifically tracking down an operation on a deleted Mutex. " 00048 "It is not guaranteed to work, of course, because the memory " 00049 "for a deleted Mutex may become reused for some other purpose.")); 00050 00051 ConfigVariableInt thread_stack_size 00052 ("thread-stack-size", 4194304, 00053 PRC_DESC("Specifies the minimum size, in bytes, of the stack that will be " 00054 "created for each newly-created thread. Not all thread " 00055 "implementations respect this value.")); 00056 00057 //////////////////////////////////////////////////////////////////// 00058 // Function: init_libpipeline 00059 // Description: Initializes the library. This must be called at 00060 // least once before any of the functions or classes in 00061 // this library can be used. Normally it will be 00062 // called by the static initializers and need not be 00063 // called explicitly, but special cases exist. 00064 //////////////////////////////////////////////////////////////////// 00065 void 00066 init_libpipeline() { 00067 static bool initialized = false; 00068 if (initialized) { 00069 return; 00070 } 00071 initialized = true; 00072 00073 AsyncTaskBase::init_type(); 00074 MainThread::init_type(); 00075 ExternalThread::init_type(); 00076 Thread::init_type(); 00077 #ifdef HAVE_PYTHON 00078 PythonThread::init_type(); 00079 #endif // HAVE_PYTHON 00080 00081 #ifdef HAVE_THREADS 00082 { 00083 PandaSystem *ps = PandaSystem::get_global_ptr(); 00084 ps->add_system("threads"); 00085 } 00086 #endif // HAVE_THREADS 00087 }