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