Panda3D

genericThread.cxx

00001 // Filename: genericThread.cxx
00002 // Created by:  drose (09Nov11)
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 #include "genericThread.h"
00016 #include "pnotify.h"
00017 
00018 TypeHandle GenericThread::_type_handle;
00019 
00020 ////////////////////////////////////////////////////////////////////
00021 //     Function: GenericThread::Constructor
00022 //       Access: Public
00023 //  Description:
00024 ////////////////////////////////////////////////////////////////////
00025 GenericThread::
00026 GenericThread(const string &name, const string &sync_name) :
00027   Thread(name, sync_name)
00028 {
00029   _function = NULL;
00030   _user_data = NULL;
00031 }
00032 
00033 ////////////////////////////////////////////////////////////////////
00034 //     Function: GenericThread::Constructor
00035 //       Access: Public
00036 //  Description:
00037 ////////////////////////////////////////////////////////////////////
00038 GenericThread::
00039 GenericThread(const string &name, const string &sync_name, GenericThread::ThreadFunc *function, void *user_data) :
00040   Thread(name, sync_name),
00041   _function(function),
00042   _user_data(user_data)
00043 {
00044 }
00045 
00046 ////////////////////////////////////////////////////////////////////
00047 //     Function: GenericThread::thread_main
00048 //       Access: Protected, Virtual
00049 //  Description: This is the thread's main execution function.
00050 ////////////////////////////////////////////////////////////////////
00051 void GenericThread::
00052 thread_main() {
00053   nassertv(_function != NULL);
00054   (*_function)(_user_data);
00055 }
 All Classes Functions Variables Enumerations