Jack2 1.9.6
|
00001 /* 00002 Copyright (C) 2004-2008 Grame 00003 00004 This program is free software; you can redistribute it and/or modify 00005 it under the terms of the GNU Lesser General Public License as published by 00006 the Free Software Foundation; either version 2.1 of the License, or 00007 (at your option) any later version. 00008 00009 This program is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 GNU Lesser General Public License for more details. 00013 00014 You should have received a copy of the GNU Lesser General Public License 00015 along with this program; if not, write to the Free Software 00016 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00017 00018 */ 00019 00020 00021 00022 #ifndef __JackWinThread__ 00023 #define __JackWinThread__ 00024 00025 #include "JackThread.h" 00026 #include "JackCompilerDeps.h" 00027 #include "JackSystemDeps.h" 00028 #include <windows.h> 00029 00030 namespace Jack 00031 { 00032 00033 typedef DWORD (WINAPI *ThreadCallback)(void *arg); 00034 00039 class SERVER_EXPORT JackWinThread : public detail::JackThreadInterface 00040 { 00041 00042 private: 00043 00044 HANDLE fThread; 00045 HANDLE fEvent; 00046 00047 static DWORD WINAPI ThreadHandler(void* arg); 00048 00049 public: 00050 00051 JackWinThread(JackRunnableInterface* runnable); 00052 ~JackWinThread(); 00053 00054 int Start(); 00055 int StartSync(); 00056 int Kill(); 00057 int Stop(); 00058 void Terminate(); 00059 00060 int AcquireRealTime(); // Used when called from another thread 00061 int AcquireSelfRealTime(); // Used when called from thread itself 00062 00063 int AcquireRealTime(int priority); // Used when called from another thread 00064 int AcquireSelfRealTime(int priority); // Used when called from thread itself 00065 00066 int DropRealTime(); // Used when called from another thread 00067 int DropSelfRealTime(); // Used when called from thread itself 00068 00069 pthread_t GetThreadID(); 00070 00071 static int AcquireRealTimeImp(pthread_t thread, int priority); 00072 static int AcquireRealTimeImp(pthread_t thread, int priority, UInt64 period, UInt64 computation, UInt64 constraint) 00073 { 00074 return JackWinThread::AcquireRealTimeImp(thread, priority); 00075 } 00076 static int DropRealTimeImp(pthread_t thread); 00077 static int StartImp(pthread_t* thread, int priority, int realtime, void*(*start_routine)(void*), void* arg) 00078 { 00079 return JackWinThread::StartImp(thread, priority, realtime, (ThreadCallback) start_routine, arg); 00080 } 00081 static int StartImp(pthread_t* thread, int priority, int realtime, ThreadCallback start_routine, void* arg); 00082 static int StopImp(pthread_t thread); 00083 static int KillImp(pthread_t thread); 00084 00085 }; 00086 00087 SERVER_EXPORT void ThreadExit(); 00088 00089 } // end of namespace 00090 00091 #endif 00092