Panda3D
genericThread.cxx
1 // Filename: genericThread.cxx
2 // Created by: drose (09Nov11)
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 #include "genericThread.h"
16 #include "pnotify.h"
17 
18 TypeHandle GenericThread::_type_handle;
19 
20 ////////////////////////////////////////////////////////////////////
21 // Function: GenericThread::Constructor
22 // Access: Public
23 // Description:
24 ////////////////////////////////////////////////////////////////////
25 GenericThread::
26 GenericThread(const string &name, const string &sync_name) :
27  Thread(name, sync_name)
28 {
29  _function = NULL;
30  _user_data = NULL;
31 }
32 
33 ////////////////////////////////////////////////////////////////////
34 // Function: GenericThread::Constructor
35 // Access: Public
36 // Description:
37 ////////////////////////////////////////////////////////////////////
38 GenericThread::
39 GenericThread(const string &name, const string &sync_name, GenericThread::ThreadFunc *function, void *user_data) :
40  Thread(name, sync_name),
41  _function(function),
42  _user_data(user_data)
43 {
44 }
45 
46 ////////////////////////////////////////////////////////////////////
47 // Function: GenericThread::thread_main
48 // Access: Protected, Virtual
49 // Description: This is the thread's main execution function.
50 ////////////////////////////////////////////////////////////////////
51 void GenericThread::
52 thread_main() {
53  nassertv(_function != NULL);
54  (*_function)(_user_data);
55 }
A thread; that is, a lightweight process.
Definition: thread.h:51
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85