Panda3D
config_pipeline.cxx
1 // Filename: config_pipeline.cxx
2 // Created by: drose (28Mar06)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #include "config_pipeline.h"
16 #include "asyncTaskBase.h"
17 #include "mainThread.h"
18 #include "externalThread.h"
19 #include "genericThread.h"
20 #include "thread.h"
21 #include "pythonThread.h"
22 #include "pandaSystem.h"
23 
24 #include "dconfig.h"
25 
26 ConfigureDef(config_pipeline);
27 NotifyCategoryDef(pipeline, "");
28 NotifyCategoryDef(thread, "");
29 
30 ConfigureFn(config_pipeline) {
31  init_libpipeline();
32 }
33 
34 ConfigVariableBool support_threads
35 ("support-threads", true,
36  PRC_DESC("Set this false to disallow the creation of threads using Panda's "
37  "Thread interface, even if threading support is compiled in. This "
38  "does not affect the operation of mutexes and other synchronization "
39  "primitives, just the creation of threads."));
40 
41 ConfigVariableBool name_deleted_mutexes
42 ("name-deleted-mutexes", false,
43  PRC_DESC("Set this true to allocate a name to each Mutex object that "
44  "destructs, so if the Mutex is locked after destruction, we can "
45  "print out its name to aid debugging. This is only available "
46  "when compiled with DEBUG_THREADS. Enabling this variable will "
47  "cause a memory leak, so you should only enable it when you are "
48  "specifically tracking down an operation on a deleted Mutex. "
49  "It is not guaranteed to work, of course, because the memory "
50  "for a deleted Mutex may become reused for some other purpose."));
51 
52 ConfigVariableInt thread_stack_size
53 ("thread-stack-size", 4194304,
54  PRC_DESC("Specifies the minimum size, in bytes, of the stack that will be "
55  "created for each newly-created thread. Not all thread "
56  "implementations respect this value."));
57 
58 ////////////////////////////////////////////////////////////////////
59 // Function: init_libpipeline
60 // Description: Initializes the library. This must be called at
61 // least once before any of the functions or classes in
62 // this library can be used. Normally it will be
63 // called by the static initializers and need not be
64 // called explicitly, but special cases exist.
65 ////////////////////////////////////////////////////////////////////
66 void
67 init_libpipeline() {
68  static bool initialized = false;
69  if (initialized) {
70  return;
71  }
72  initialized = true;
73 
74  AsyncTaskBase::init_type();
75  MainThread::init_type();
76  ExternalThread::init_type();
77  GenericThread::init_type();
78  Thread::init_type();
79 #ifdef HAVE_PYTHON
80  PythonThread::init_type();
81 #endif // HAVE_PYTHON
82 
83 #ifdef HAVE_THREADS
84  {
86  ps->add_system("threads");
87  }
88 #endif // HAVE_THREADS
89 }
static PandaSystem * get_global_ptr()
Returns the global PandaSystem object.
This class is used as a namespace to group several global properties of Panda.
Definition: pandaSystem.h:29
This is a convenience class to specialize ConfigVariable as a boolean type.
void add_system(const string &system)
Intended for use by each subsystem to register itself at startup.
This is a convenience class to specialize ConfigVariable as an integer type.