Update changelog
[jack2.git] / windows / JackWinThread.h
blobdcc19e8d1f42fca156ebbdcf8d622d2a38e15613
1 /*
2 Copyright (C) 2004-2008 Grame
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.
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.
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.
20 #ifndef __JackWinThread__
21 #define __JackWinThread__
23 #include "JackThread.h"
24 #include "JackMMCSS.h"
25 #include "JackCompilerDeps.h"
26 #include "JackSystemDeps.h"
27 #ifdef __MINGW32__
28 #include <winsock2.h>
29 #endif
30 #include <windows.h>
32 namespace Jack
35 typedef DWORD (WINAPI *ThreadCallback)(void *arg);
37 /*!
38 \brief Windows threads.
41 class SERVER_EXPORT JackWinThread : public JackMMCSS, public detail::JackThreadInterface
44 private:
46 HANDLE fThread;
47 HANDLE fEvent;
49 static DWORD WINAPI ThreadHandler(void* arg);
51 public:
53 JackWinThread(JackRunnableInterface* runnable);
54 ~JackWinThread();
56 int Start();
57 int StartSync();
58 int Kill();
59 int Stop();
60 void Terminate();
62 int AcquireRealTime(); // Used when called from another thread
63 int AcquireSelfRealTime(); // Used when called from thread itself
65 int AcquireRealTime(int priority); // Used when called from another thread
66 int AcquireSelfRealTime(int priority); // Used when called from thread itself
68 int DropRealTime(); // Used when called from another thread
69 int DropSelfRealTime(); // Used when called from thread itself
71 jack_native_thread_t GetThreadID();
72 bool IsThread();
74 static int AcquireRealTimeImp(jack_native_thread_t thread, int priority);
75 static int AcquireRealTimeImp(jack_native_thread_t thread, int priority, UInt64 period, UInt64 computation, UInt64 constraint)
77 return JackWinThread::AcquireRealTimeImp(thread, priority);
79 static int DropRealTimeImp(jack_native_thread_t thread);
80 static int StartImp(jack_native_thread_t* thread, int priority, int realtime, void*(*start_routine)(void*), void* arg)
82 return JackWinThread::StartImp(thread, priority, realtime, (ThreadCallback) start_routine, arg);
84 static int StartImp(jack_native_thread_t* thread, int priority, int realtime, ThreadCallback start_routine, void* arg);
85 static int StopImp(jack_native_thread_t thread);
86 static int KillImp(jack_native_thread_t thread);
90 SERVER_EXPORT void ThreadExit();
92 } // end of namespace
94 #endif