lib: show offset and rectype in HexDumpParser
[barry.git] / src / threadwrap.cc
blobd48914215234d2d8a5c702dcf22f2e28840ad0e4
1 ///
2 /// \file threadwrap.cc
3 /// RAII Wrapper for a single thread.
4 ///
6 /*
7 Copyright (C) 2009, Nicolas VIVIEN
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 See the GNU General Public License in the COPYING file at the
19 root directory of this project for more details.
22 #include "threadwrap.h"
23 #include "error.h"
26 namespace Barry {
28 Thread::Thread(int socket, void *(*callback)(void *data), void *data)
30 int ret = pthread_create(&thread, NULL, callback, data);
31 if( ret ) {
32 throw Barry::ErrnoError("Thread: pthread_create failed.", ret);
37 Thread::~Thread()
39 pthread_join(thread, NULL);
43 void Thread::Dispose()
45 int ret = pthread_cancel(thread);
46 if( ret ) {
47 throw Barry::ErrnoError("Thread: pthread_cancel failed.", ret);
51 } // namespace Barry