Panda3D
threadWin32Impl.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 threadWin32Impl.h
10  * @author drose
11  * @date 2006-02-07
12  */
13 
14 #ifndef THREADWIN32IMPL_H
15 #define THREADWIN32IMPL_H
16 
17 #include "pandabase.h"
18 #include "selectThreadImpl.h"
19 
20 #ifdef THREAD_WIN32_IMPL
21 
22 #include "pnotify.h"
23 #include "threadPriority.h"
24 #include "mutexWin32Impl.h"
25 #include "conditionVarWin32Impl.h"
26 
27 class Thread;
28 
29 /**
30  * Uses native Windows calls to implement a thread.
31  */
32 class EXPCL_PANDA_PIPELINE ThreadWin32Impl {
33 public:
34  INLINE ThreadWin32Impl(Thread *parent_obj);
35  ~ThreadWin32Impl();
36 
37  void setup_main_thread();
38  bool start(ThreadPriority priority, bool joinable);
39  void join();
40  INLINE void preempt();
41 
42  std::string get_unique_id() const;
43 
44  INLINE static void prepare_for_exit();
45 
46  INLINE static Thread *get_current_thread();
47  INLINE static void bind_thread(Thread *thread);
48  INLINE static bool is_threading_supported();
49  INLINE static bool is_true_threads();
50  INLINE static bool is_simple_threads();
51  INLINE static void sleep(double seconds);
52  INLINE static void yield();
53  INLINE static void consider_yield();
54 
55 private:
56  static DWORD WINAPI root_func(LPVOID data);
57  static void init_pt_ptr_index();
58 
59  enum Status {
60  S_new,
61  S_start_called,
62  S_running,
63  S_finished
64  };
65 
66  MutexWin32Impl _mutex;
67  ConditionVarWin32Impl _cv;
68  Thread *_parent_obj;
69  HANDLE _thread;
70  DWORD _thread_id;
71  bool _joinable;
72  Status _status;
73 
74  static DWORD _pt_ptr_index;
75  static bool _got_pt_ptr_index;
76 };
77 
78 #include "threadWin32Impl.I"
79 
80 #endif // THREAD_WIN32_IMPL
81 
82 #endif
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A thread; that is, a lightweight process.
Definition: thread.h:46
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.