2 Copyright (C) 2001 Paul Davis
3 Copyright (C) 2004-2006 Grame
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #ifndef __JackThread__
22 #define __JackThread__
26 typedef HANDLE pthread_t
;
27 typedef ULONGLONG UInt64
;
30 typedef unsigned long long UInt64
;
37 \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 class JackRunnableInterface
45 JackRunnableInterface()
47 virtual ~JackRunnableInterface()
50 virtual bool Init() /*! Called once when the thread is started */
54 virtual bool Execute() = 0; /*! Must be implemented by subclasses */
58 \brief The thread base class.
66 JackRunnableInterface
* fRunnable
;
69 volatile bool fRunning
;
74 JackThread(JackRunnableInterface
* runnable
, int priority
, bool real_time
, int cancellation
):
75 fRunnable(runnable
), fPriority(priority
), fRealTime(real_time
), fRunning(false), fCancellation(cancellation
)
80 virtual int Start() = 0;
81 virtual int StartSync() = 0;
82 virtual int Kill() = 0;
83 virtual int Stop() = 0;
85 virtual int AcquireRealTime() = 0;
86 virtual int AcquireRealTime(int priority
) = 0;
87 virtual int DropRealTime() = 0;
89 virtual void SetParams(UInt64 period
, UInt64 computation
, UInt64 constraint
) // Empty implementation, will only make sense on OSX...
92 virtual pthread_t
GetThreadID() = 0;