ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/truck/Common/threads.cpp
Revision: 31
Committed: 2008-02-28T22:06:06-08:00 (14 years, 4 months ago) by douglas
File size: 1965 byte(s)
Log Message:
Snarfed some Menes code...

File Contents

# Content
1 // Truck Computer Dooom!
2 //
3 // Douglas Thrift
4 //
5 // $Id$
6
7 /* Menes - C++ High-Level Utility Library
8 * Copyright (C) 2002-2005 Jay Freeman (saurik)
9 */
10
11 /*
12 * Redistribution and use in source and binary
13 * forms, with or without modification, are permitted
14 * provided that the following conditions are met:
15 *
16 * 1. Redistributions of source code must retain the
17 * above copyright notice, this list of conditions
18 * and the following disclaimer.
19 * 2. Redistributions in binary form must reproduce the
20 * above copyright notice, this list of conditions
21 * and the following disclaimer in the documentation
22 * and/or other materials provided with the
23 * distribution.
24 * 3. The name of the author may not be used to endorse
25 * or promote products derived from this software
26 * without specific prior written permission.
27 *
28 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS''
29 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
30 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
31 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
32 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE
33 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
34 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
35 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
36 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
37 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
38 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
39 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
40 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
41 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
42 */
43
44 #include "threads.hpp"
45
46 namespace Pthreads
47 {
48
49 Thread::Thread(Function function, void *argument) : joinable(true)
50 {
51 CheckError(::pthread_create(&thread, NULL, function, argument));
52 }
53
54 Thread::~Thread()
55 {
56 if (joinable)
57 CheckError(::pthread_detach(thread));
58 }
59
60 void Thread::Join() const
61 {
62 CheckError(::pthread_join(thread, NULL));
63
64 joinable = false;
65 }
66
67 }

Properties

Name Value
svn:keywords Id