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
00022 #include "threadwrap.h"
00023 #include "error.h"
00024
00025
00026 namespace Barry {
00027
00028 Thread::Thread(int socket, void *(*callback)(void *data), void *data)
00029 {
00030 int ret = pthread_create(&thread, NULL, callback, data);
00031 if( ret ) {
00032 throw Barry::ErrnoError("Thread: pthread_create failed.", ret);
00033 }
00034 }
00035
00036
00037 Thread::~Thread()
00038 {
00039 pthread_join(thread, NULL);
00040 }
00041
00042
00043 void Thread::Dispose()
00044 {
00045 int ret = pthread_cancel(thread);
00046 if( ret ) {
00047 throw Barry::ErrnoError("Thread: pthread_cancel failed.", ret);
00048 }
00049 }
00050
00051 }
00052