Panda3D
 All Classes Functions Variables Enumerations
selectThreadImpl.h
1 // Filename: selectThreadImpl.h
2 // Created by: drose (09Aug02)
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 #ifndef SELECTTHREADIMPL_H
16 #define SELECTTHREADIMPL_H
17 
18 #include "dtoolbase.h"
19 
20 ////////////////////////////////////////////////////////////////////
21 // This file decides which of the core implementations of the various
22 // threading and locking implementations we should use, based on
23 // platform and/or available libraries.
24 //
25 // This file, along with mutexImpl.h and the various Mutex
26 // implementation classes, are defined in dtool so that some form of
27 // critical-section protection will be available to view low-level
28 // classes like TypeRegistry. Most of the rest of the threading and
29 // synchronization classes are defined in panda/src/express.
30 ////////////////////////////////////////////////////////////////////
31 
32 // This keyword should be used to mark any variable which is possibly
33 // volatile because multiple threads might contend on it, unprotected
34 // by a mutex. It will be defined out in the non-threaded case.
35 // Other uses for volatile (dma buffers, for instance) should use the
36 // regular volatile keyword.
37 #define TVOLATILE volatile
38 
39 #if !defined(HAVE_THREADS)
40 
41 // With threading disabled, use the do-nothing implementation.
42 #define THREAD_DUMMY_IMPL 1
43 
44 // And the TVOLATILE keyword means nothing in the absence of threads.
45 #undef TVOLATILE
46 #define TVOLATILE
47 
48 #elif defined(SIMPLE_THREADS)
49 // Use the simulated threading library.
50 #define THREAD_SIMPLE_IMPL 1
51 #undef TVOLATILE
52 #define TVOLATILE
53 
54 #elif defined(WIN32_VC)
55 
56 // In Windows, use the native threading library.
57 #define THREAD_WIN32_IMPL 1
58 
59 #elif defined(HAVE_POSIX_THREADS)
60 
61 // Posix threads are nice.
62 #define THREAD_POSIX_IMPL 1
63 
64 #else
65 
66 // This is a configuration error. For some reason, HAVE_THREADS is
67 // defined but we don't have any way to implement it.
68 #error No thread implementation defined for platform.
69 
70 #endif
71 
72 // Let's also factor out some of the other configuration variables.
73 #if defined(DO_PIPELINING) && defined(HAVE_THREADS)
74 #define THREADED_PIPELINE 1
75 #else
76 #undef THREADED_PIPELINE
77 #endif
78 
79 #endif