Panda3D
threadWin32Impl.I
1 // Filename: threadWin32Impl.I
2 // Created by: drose (07Feb06)
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 
16 ////////////////////////////////////////////////////////////////////
17 // Function: ThreadWin32Impl::Constructor
18 // Access: Public
19 // Description:
20 ////////////////////////////////////////////////////////////////////
21 INLINE ThreadWin32Impl::
22 ThreadWin32Impl(Thread *parent_obj) :
23  _cv(_mutex),
24  _parent_obj(parent_obj)
25 {
26  _thread = 0;
27  _joinable = false;
28  _status = S_new;
29 }
30 
31 ////////////////////////////////////////////////////////////////////
32 // Function: ThreadWin32Impl::preempt
33 // Access: Public
34 // Description:
35 ////////////////////////////////////////////////////////////////////
36 INLINE void ThreadWin32Impl::
37 preempt() {
38 }
39 
40 ////////////////////////////////////////////////////////////////////
41 // Function: ThreadWin32Impl::prepare_for_exit
42 // Access: Public
43 // Description:
44 ////////////////////////////////////////////////////////////////////
45 INLINE void ThreadWin32Impl::
46 prepare_for_exit() {
47 }
48 
49 ////////////////////////////////////////////////////////////////////
50 // Function: ThreadWin32Impl::get_current_thread
51 // Access: Public, Static
52 // Description:
53 ////////////////////////////////////////////////////////////////////
54 INLINE Thread *ThreadWin32Impl::
55 get_current_thread() {
56  if (!_got_pt_ptr_index) {
57  init_pt_ptr_index();
58  }
59  return (Thread *)TlsGetValue(_pt_ptr_index);
60 }
61 
62 ////////////////////////////////////////////////////////////////////
63 // Function: ThreadWin32Impl::bind_thread
64 // Access: Public, Static
65 // Description: Associates the indicated Thread object with the
66 // currently-executing thread. You should not call this
67 // directly; use Thread::bind_thread() instead.
68 ////////////////////////////////////////////////////////////////////
69 INLINE void ThreadWin32Impl::
70 bind_thread(Thread *thread) {
71  if (!_got_pt_ptr_index) {
72  init_pt_ptr_index();
73  }
74  BOOL result = TlsSetValue(_pt_ptr_index, thread);
75  nassertv(result);
76 }
77 
78 ////////////////////////////////////////////////////////////////////
79 // Function: ThreadWin32Impl::is_threading_supported
80 // Access: Public, Static
81 // Description:
82 ////////////////////////////////////////////////////////////////////
83 INLINE bool ThreadWin32Impl::
84 is_threading_supported() {
85  return true;
86 }
87 
88 ////////////////////////////////////////////////////////////////////
89 // Function: ThreadWin32Impl::is_true_threads
90 // Access: Public, Static
91 // Description:
92 ////////////////////////////////////////////////////////////////////
93 INLINE bool ThreadWin32Impl::
94 is_true_threads() {
95  return true;
96 }
97 
98 ////////////////////////////////////////////////////////////////////
99 // Function: ThreadWin32Impl::is_simple_threads
100 // Access: Public, Static
101 // Description:
102 ////////////////////////////////////////////////////////////////////
103 INLINE bool ThreadWin32Impl::
104 is_simple_threads() {
105  return false;
106 }
107 
108 ////////////////////////////////////////////////////////////////////
109 // Function: ThreadWin32Impl::sleep
110 // Access: Public, Static
111 // Description:
112 ////////////////////////////////////////////////////////////////////
113 INLINE void ThreadWin32Impl::
114 sleep(double seconds) {
115  Sleep((int)(seconds * 1000));
116 }
117 
118 ////////////////////////////////////////////////////////////////////
119 // Function: ThreadWin32Impl::yield
120 // Access: Public, Static
121 // Description:
122 ////////////////////////////////////////////////////////////////////
123 INLINE void ThreadWin32Impl::
124 yield() {
125  Sleep(1);
126 }
127 
128 ////////////////////////////////////////////////////////////////////
129 // Function: ThreadWin32Impl::consider_yield
130 // Access: Public, Static
131 // Description:
132 ////////////////////////////////////////////////////////////////////
133 INLINE void ThreadWin32Impl::
134 consider_yield() {
135 }
A thread; that is, a lightweight process.
Definition: thread.h:51