Panda3D
threadDummyImpl.h
1 // Filename: threadDummyImpl.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 THREADDUMMYIMPL_H
16 #define THREADDUMMYIMPL_H
17 
18 #include "pandabase.h"
19 #include "selectThreadImpl.h"
20 
21 #ifdef THREAD_DUMMY_IMPL
22 
23 #include "pnotify.h"
24 #include "threadPriority.h"
25 
26 class Thread;
27 
28 #ifdef WIN32
29 #ifndef WIN32_LEAN_AND_MEAN
30 #define WIN32_LEAN_AND_MEAN 1
31 #endif
32 #include <windows.h> // For Sleep().
33 #endif
34 
35 ////////////////////////////////////////////////////////////////////
36 // Class : ThreadDummyImpl
37 // Description : A fake thread implementation for single-threaded
38 // applications. This simply fails whenever you try to
39 // start a thread.
40 ////////////////////////////////////////////////////////////////////
41 class EXPCL_PANDA_PIPELINE ThreadDummyImpl {
42 public:
43  INLINE ThreadDummyImpl(Thread *parent_obj);
44  INLINE ~ThreadDummyImpl();
45 
46  INLINE void setup_main_thread();
47  INLINE bool start(ThreadPriority priority, bool joinable);
48  INLINE void join();
49  INLINE void preempt();
50 
51  string get_unique_id() const;
52 
53  INLINE static void prepare_for_exit();
54 
55  static Thread *get_current_thread();
56  INLINE static void bind_thread(Thread *thread);
57  INLINE static bool is_threading_supported();
58  INLINE static bool is_true_threads();
59  INLINE static bool is_simple_threads();
60  INLINE static void sleep(double seconds);
61  INLINE static void yield();
62  INLINE static void consider_yield();
63 };
64 
65 #include "threadDummyImpl.I"
66 
67 #endif // THREAD_DUMMY_IMPL
68 
69 #endif
A thread; that is, a lightweight process.
Definition: thread.h:51