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

Revision 445, 2.2 kB (checked in by pieterpalmers, 17 years ago)

* name change from FreeBoB to FFADO
* replaced tabs by 4 spaces
* got rid of end-of-line spaces
* made all license and copyrights conform

library becomes LGPL, apps become GPL
explicitly state LGPL v2.1 and GPL v2 (don't like v3 draft)

copyrights are 2005-2007 Daniel & Pieter
except for the MotU stuff (C) Jonathan, Pieter

Line 
1 /*
2 Modifications for FFADO by Pieter Palmers
3
4 Copied from the jackd/jackdmp sources
5 function names changed in order to avoid naming problems when using this in
6 a jackd backend.
7
8 Copyright (C) 2001 Paul Davis
9 Copyright (C) 2004-2006 Grame
10
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 2 of the License, or
14 (at your option) any later version.
15
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 GNU General Public License for more details.
20
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24
25 */
26
27 #ifndef __THREAD__
28 #define __THREAD__
29
30 #include "../debugmodule/debugmodule.h"
31
32 #include "Atomic.h"
33 #include <pthread.h>
34
35 namespace Util
36 {
37
38 /*!
39 \brief The base class for runnable objects, that have an <B> Init </B> and <B> Execute </B> method to be called in a thread.
40 */
41
42 class RunnableInterface
43 {
44
45     public:
46
47         RunnableInterface()
48         {}
49         virtual ~RunnableInterface()
50         {}
51
52         virtual bool Init()          /*! Called once when the thread is started */
53         {
54             return true;
55         }
56         virtual bool Execute() = 0;  /*! Must be implemented by subclasses */
57 };
58
59 /*!
60 \brief The thread base class.
61 */
62
63 class Thread
64 {
65
66     protected:
67
68         RunnableInterface* fRunnable;
69
70     public:
71
72         Thread(RunnableInterface* runnable): fRunnable(runnable)
73         {}
74         virtual ~Thread()
75         {}
76
77         virtual int Start() = 0;
78         virtual int Kill() = 0;
79         virtual int Stop() = 0;
80
81         virtual int AcquireRealTime() = 0;
82         virtual int AcquireRealTime(int priority) = 0;
83         virtual int DropRealTime() = 0;
84
85         virtual void SetParams(UInt64 period, UInt64 computation, UInt64 constraint) // Empty implementation, will only make sense on OSX...
86         {}
87
88         virtual pthread_t GetThreadID() = 0;
89
90     protected:
91             DECLARE_DEBUG_MODULE;
92
93 };
94
95 } // end of namespace
96
97 #endif
Note: See TracBrowser for help on using the browser.