root/trunk/libffado/src/libutil/PosixThread.h

Revision 864, 3.2 kB (checked in by ppalmers, 14 years ago)

update license to GPLv2 or GPLv3 instead of GPLv2 or any later version. Update copyrights to reflect the new year

Line 
1 /*
2  * Copyright (C) 2005-2008 by Pieter Palmers
3  *
4  * This file is part of FFADO
5  * FFADO = Free Firewire (pro-)audio drivers for linux
6  *
7  * FFADO is based upon FreeBoB
8  *
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) version 3 of the License.
13  *
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.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
21  *
22  */
23
24 /*
25  * Copied from the jackd/jackdmp sources
26  * function names changed in order to avoid naming problems when using this in
27  * a jackd backend.
28  */
29
30 /* Original license:
31  *
32  *  Copyright (C) 2001 Paul Davis
33  *  Copyright (C) 2004-2006 Grame
34  *
35  *  This program is free software; you can redistribute it and/or modify
36  *  it under the terms of the GNU General Public License as published by
37  *  the Free Software Foundation; either version 2 of the License, or
38  *  (at your option) version 3 of the License.
39  *
40  *  This program is distributed in the hope that it will be useful,
41  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
42  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
43  *  GNU General Public License for more details.
44  *
45  *  You should have received a copy of the GNU General Public License
46  *  along with this program; if not, write to the Free Software
47  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
48  *
49  */
50
51 #ifndef __FFADO_POSIXTHREAD__
52 #define __FFADO_POSIXTHREAD__
53
54 #include "Thread.h"
55 #include <pthread.h>
56
57 namespace Util
58 {
59
60 /*!
61 \brief The POSIX thread base class.
62 */
63
64 class PosixThread : public Thread
65 {
66
67     protected:
68
69         pthread_t fThread;
70         int fPriority;
71         bool fRealTime;
72         volatile bool fRunning;
73         int fCancellation;
74
75         static void* ThreadHandler(void* arg);
76
77     public:
78
79         PosixThread(RunnableInterface* runnable, bool real_time, int priority, int cancellation)
80                 : Thread(runnable), fThread((pthread_t)NULL), fPriority(priority), fRealTime(real_time), fRunning(false), fCancellation(cancellation)
81         {}
82         PosixThread(RunnableInterface* runnable)
83                 : Thread(runnable), fThread((pthread_t)NULL), fPriority(0), fRealTime(false), fRunning(false), fCancellation(PTHREAD_CANCEL_DEFERRED)
84         {}
85         PosixThread(RunnableInterface* runnable, int cancellation)
86                 : Thread(runnable), fThread((pthread_t)NULL), fPriority(0), fRealTime(false), fRunning(false), fCancellation(cancellation)
87         {}
88
89         virtual ~PosixThread()
90         {}
91
92         virtual int Start();
93         virtual int Kill();
94         virtual int Stop();
95
96         virtual int AcquireRealTime();
97         virtual int AcquireRealTime(int priority);
98         virtual int DropRealTime();
99
100         pthread_t GetThreadID();
101
102     protected:
103
104 };
105
106 } // end of namespace
107
108
109 #endif // __FFADO_POSIXTHREAD__
Note: See TracBrowser for help on using the browser.