Jack2 1.9.12

JackWinThread.h
1 /*
2 Copyright (C) 2004-2008 Grame
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as published by
6 the Free Software Foundation; either version 2.1 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
18 */
19
20 #ifndef __JackWinThread__
21 #define __JackWinThread__
22
23 #include "JackThread.h"
24 #include "JackMMCSS.h"
25 #include "JackCompilerDeps.h"
26 #include "JackSystemDeps.h"
27 #include <windows.h>
28
29 namespace Jack
30 {
31
32 typedef DWORD (WINAPI *ThreadCallback)(void *arg);
33
38 class SERVER_EXPORT JackWinThread : public JackMMCSS, public detail::JackThreadInterface
39 {
40
41 private:
42
43 HANDLE fThread;
44 HANDLE fEvent;
45
46 static DWORD WINAPI ThreadHandler(void* arg);
47
48 public:
49
50 JackWinThread(JackRunnableInterface* runnable);
51 ~JackWinThread();
52
53 int Start();
54 int StartSync();
55 int Kill();
56 int Stop();
57 void Terminate();
58
59 int AcquireRealTime(); // Used when called from another thread
60 int AcquireSelfRealTime(); // Used when called from thread itself
61
62 int AcquireRealTime(int priority); // Used when called from another thread
63 int AcquireSelfRealTime(int priority); // Used when called from thread itself
64
65 int DropRealTime(); // Used when called from another thread
66 int DropSelfRealTime(); // Used when called from thread itself
67
68 jack_native_thread_t GetThreadID();
69 bool IsThread();
70
71 static int AcquireRealTimeImp(jack_native_thread_t thread, int priority);
72 static int AcquireRealTimeImp(jack_native_thread_t thread, int priority, UInt64 period, UInt64 computation, UInt64 constraint)
73 {
74 return JackWinThread::AcquireRealTimeImp(thread, priority);
75 }
76 static int DropRealTimeImp(jack_native_thread_t thread);
77 static int StartImp(jack_native_thread_t* thread, int priority, int realtime, void*(*start_routine)(void*), void* arg)
78 {
79 return JackWinThread::StartImp(thread, priority, realtime, (ThreadCallback) start_routine, arg);
80 }
81 static int StartImp(jack_native_thread_t* thread, int priority, int realtime, ThreadCallback start_routine, void* arg);
82 static int StopImp(jack_native_thread_t thread);
83 static int KillImp(jack_native_thread_t thread);
84
85 };
86
87 SERVER_EXPORT void ThreadExit();
88
89 } // end of namespace
90
91 #endif
92
Jack::detail::JackThreadInterface
The thread base class.
Definition: JackThread.h:60
Jack::JackMMCSS
MMCSS services.
Definition: JackMMCSS.h:50
Jack::JackRunnableInterface
The base class for runnable objects, that have an Init and Execute method to be called in a threa...
Definition: JackThread.h:34
Jack::JackWinThread
Windows threads.
Definition: JackWinThread.h:38