cthread.cc
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <cthread.hxx>
00022 #include <iostream>
00023
00024 namespace control {
00025
00026 void *thread_start_entry(void* thread_inst)
00027 {
00028 cthread* inst = (cthread*) thread_inst;
00030 inst->run_.emit();
00031
00033 return 0l;
00034 }
00035
00036
00037 cthread::cthread(): sigc::trackable()
00038 {
00039 }
00040
00041 cthread::cthread(const std::string& nameid, const sigc::slot<bool>& exec_hook): trackable()
00042 {
00043 _name = nameid;
00044 run_.connect( exec_hook );
00045 }
00046
00047 cthread::~cthread()
00048 {
00049 std::cerr << __PRETTY_FUNCTION__ << std::endl << '{' << std::endl << name() << std::endl;
00050 run_.clear();
00051 end_.clear();
00052 notify_.clear();
00053 pthread_cancel(_pthID);
00054 std::cerr << "thread exited ?" << std::endl;
00055 std::cerr << std::endl << '}' << std::endl;
00056 }
00057
00058
00059
00060
00061
00070 bool cthread::run()
00071 {
00072 int rc = pthread_create( &_pthID, 0l, thread_start_entry, (void*)this);
00073 if(rc) return false;
00074 return true;
00075 }
00076
00077
00083 bool cthread::exec_delegate( const sigc::slot<bool>& exec_hook)
00084 {
00085 run_.connect( exec_hook);
00086 return true;
00087 }
00088
00089
00094 bool cthread::exit()
00095 {
00096 std::cerr << __PRETTY_FUNCTION__ << std::endl << '{' << std::endl << "." << std::endl;
00097
00098 if(!end_.empty()) end_.emit();
00099 pthread_cancel(_pthID);
00100 std::cerr << std::endl << '}' << std::endl;
00101
00102 return true;
00103 }
00104
00105 }
00106
00107
API Documentation Generated by:
1.4.0
About the author |

Site started with trial version of DreamWeaver MX 2004 |
Finalizing with

|
Contact | ©2005, Serge Lussier ( Bretzel )