Panda3D
|
00001 // Filename: selectThreadImpl.h 00002 // Created by: drose (09Aug02) 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 #ifndef SELECTTHREADIMPL_H 00016 #define SELECTTHREADIMPL_H 00017 00018 #include "dtoolbase.h" 00019 00020 //////////////////////////////////////////////////////////////////// 00021 // This file decides which of the core implementations of the various 00022 // threading and locking implementations we should use, based on 00023 // platform and/or available libraries. 00024 // 00025 // This file, along with mutexImpl.h and the various Mutex 00026 // implementation classes, are defined in dtool so that some form of 00027 // critical-section protection will be available to view low-level 00028 // classes like TypeRegistry. Most of the rest of the threading and 00029 // synchronization classes are defined in panda/src/express. 00030 //////////////////////////////////////////////////////////////////// 00031 00032 // This keyword should be used to mark any variable which is possibly 00033 // volatile because multiple threads might contend on it, unprotected 00034 // by a mutex. It will be defined out in the non-threaded case. 00035 // Other uses for volatile (dma buffers, for instance) should use the 00036 // regular volatile keyword. 00037 #define TVOLATILE volatile 00038 00039 #if !defined(HAVE_THREADS) 00040 00041 // With threading disabled, use the do-nothing implementation. 00042 #define THREAD_DUMMY_IMPL 1 00043 00044 // And the TVOLATILE keyword means nothing in the absence of threads. 00045 #undef TVOLATILE 00046 #define TVOLATILE 00047 00048 #elif defined(SIMPLE_THREADS) 00049 // Use the simulated threading library. 00050 #define THREAD_SIMPLE_IMPL 1 00051 #undef TVOLATILE 00052 #define TVOLATILE 00053 00054 #elif defined(WIN32_VC) 00055 00056 // In Windows, use the native threading library. 00057 #define THREAD_WIN32_IMPL 1 00058 00059 #elif defined(HAVE_POSIX_THREADS) 00060 00061 // Posix threads are nice. 00062 #define THREAD_POSIX_IMPL 1 00063 00064 #else 00065 00066 // This is a configuration error. For some reason, HAVE_THREADS is 00067 // defined but we don't have any way to implement it. 00068 #error No thread implementation defined for platform. 00069 00070 #endif 00071 00072 // Let's also factor out some of the other configuration variables. 00073 #if defined(DO_PIPELINING) && defined(HAVE_THREADS) 00074 #define THREADED_PIPELINE 1 00075 #else 00076 #undef THREADED_PIPELINE 00077 #endif 00078 00079 #endif