Panda3D
selectThreadImpl.h
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file selectThreadImpl.h
10  * @author drose
11  * @date 2002-08-09
12  */
13 
14 #ifndef SELECTTHREADIMPL_H
15 #define SELECTTHREADIMPL_H
16 
17 #include "dtoolbase.h"
18 
19 /*
20  * This file decides which of the core implementations of the various
21  * threading and locking implementations we should use, based on platform
22  * andor available libraries. This file, along with mutexImpl.h and the
23  * various Mutex implementation classes, are defined in dtool so that some
24  * form of critical-section protection will be available to view low-level
25  * classes like TypeRegistry. Most of the rest of the threading and
26  * synchronization classes are defined in pandasrcexpress.
27  */
28 
29 // This keyword should be used to mark any variable which is possibly volatile
30 // because multiple threads might contend on it, unprotected by a mutex. It
31 // will be defined out in the non-threaded case. Other uses for volatile (dma
32 // buffers, for instance) should use the regular volatile keyword.
33 #define TVOLATILE volatile
34 
35 #if !defined(HAVE_THREADS) || defined(CPPPARSER)
36 
37 // With threading disabled, use the do-nothing implementation.
38 #define THREAD_DUMMY_IMPL 1
39 
40 // And the TVOLATILE keyword means nothing in the absence of threads.
41 #undef TVOLATILE
42 #define TVOLATILE
43 
44 #elif defined(SIMPLE_THREADS)
45 // Use the simulated threading library.
46 #define THREAD_SIMPLE_IMPL 1
47 #undef TVOLATILE
48 #define TVOLATILE
49 
50 #elif defined(WIN32_VC)
51 
52 // In Windows, use the native threading library.
53 #define THREAD_WIN32_IMPL 1
54 
55 #elif defined(HAVE_POSIX_THREADS)
56 
57 // Posix threads are nice.
58 #define THREAD_POSIX_IMPL 1
59 
60 #else
61 
62 // This is a configuration error. For some reason, HAVE_THREADS is defined
63 // but we don't have any way to implement it.
64 #error No thread implementation defined for platform.
65 
66 #endif
67 
68 // Let's also factor out some of the other configuration variables.
69 #if defined(DO_PIPELINING) && defined(HAVE_THREADS)
70 #define THREADED_PIPELINE 1
71 #else
72 #undef THREADED_PIPELINE
73 #endif
74 
75 #endif
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.