2 Copyright (C) 2001 Paul Davis
3 Copyright (C) 2004-2008 Grame
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 #ifndef __JackPosixThread__
22 #define __JackPosixThread__
24 #include "JackThread.h"
30 /* use 512KB stack per thread - the default is way too high to be feasible
31 * with mlockall() on many systems */
32 #define THREAD_STACK 524288
35 \brief The POSIX thread base class.
38 class SERVER_EXPORT JackPosixThread
: public detail::JackThreadInterface
43 jack_native_thread_t fThread
;
44 static void* ThreadHandler(void* arg
);
48 JackPosixThread(JackRunnableInterface
* runnable
, bool real_time
, int priority
, int cancellation
)
49 : JackThreadInterface(runnable
, priority
, real_time
, cancellation
), fThread((jack_native_thread_t
)NULL
)
51 JackPosixThread(JackRunnableInterface
* runnable
, int cancellation
= PTHREAD_CANCEL_ASYNCHRONOUS
)
52 : JackThreadInterface(runnable
, 0, false, cancellation
), fThread((jack_native_thread_t
)NULL
)
61 int AcquireRealTime(); // Used when called from another thread
62 int AcquireSelfRealTime(); // Used when called from thread itself
64 int AcquireRealTime(int priority
); // Used when called from another thread
65 int AcquireSelfRealTime(int priority
); // Used when called from thread itself
67 int DropRealTime(); // Used when called from another thread
68 int DropSelfRealTime(); // Used when called from thread itself
70 jack_native_thread_t
GetThreadID();
73 static int AcquireRealTimeImp(jack_native_thread_t thread
, int priority
);
74 static int AcquireRealTimeImp(jack_native_thread_t thread
, int priority
, UInt64 period
, UInt64 computation
, UInt64 constraint
)
76 return JackPosixThread::AcquireRealTimeImp(thread
, priority
);
78 static int DropRealTimeImp(jack_native_thread_t thread
);
79 static int StartImp(jack_native_thread_t
* thread
, int priority
, int realtime
, void*(*start_routine
)(void*), void* arg
);
80 static int StopImp(jack_native_thread_t thread
);
81 static int KillImp(jack_native_thread_t thread
);
84 SERVER_EXPORT
void ThreadExit();