JackThread.h

00001 /*
00002 Copyright (C) 2001 Paul Davis
00003 Copyright (C) 2004-2008 Grame
00004 
00005 This program is free software; you can redistribute it and/or modify
00006 it under the terms of the GNU General Public License as published by
00007 the Free Software Foundation; either version 2 of the License, or
00008 (at your option) any later version.
00009 
00010 This program is distributed in the hope that it will be useful,
00011 but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 GNU General Public License for more details.
00014 
00015 You should have received a copy of the GNU General Public License
00016 along with this program; if not, write to the Free Software
00017 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00018 
00019 */
00020 
00021 #ifndef __JackThread__
00022 #define __JackThread__
00023 
00024 #ifdef WIN32
00025         #include <windows.h>
00026 typedef HANDLE pthread_t;
00027 typedef ULONGLONG UInt64;
00028 #else
00029         #include <pthread.h>
00030 typedef unsigned long long UInt64;
00031 #endif
00032 
00033 namespace Jack
00034 {
00035 
00040 class JackRunnableInterface
00041 {
00042 
00043     public:
00044 
00045         JackRunnableInterface()
00046         {}
00047         virtual ~JackRunnableInterface()
00048         {}
00049 
00050         virtual bool Init()          
00051         {
00052             return true;
00053         }
00054         virtual bool Execute() = 0;  
00055 };
00056 
00061 class JackThread
00062 {
00063 
00064     protected:
00065 
00066         JackRunnableInterface* fRunnable;
00067         int fPriority;
00068         bool fRealTime;
00069         volatile bool fRunning;
00070         int fCancellation;
00071 
00072     public:
00073 
00074         JackThread(JackRunnableInterface* runnable, int priority, bool real_time, int cancellation):
00075                 fRunnable(runnable), fPriority(priority), fRealTime(real_time), fRunning(false), fCancellation(cancellation)
00076         {}
00077         virtual ~JackThread()
00078         {}
00079 
00080         virtual int Start() = 0;
00081         virtual int StartSync() = 0;
00082         virtual int Kill() = 0;
00083         virtual int Stop() = 0;
00084                 virtual void Terminate() = 0;
00085 
00086         virtual int AcquireRealTime() = 0;
00087         virtual int AcquireRealTime(int priority) = 0;
00088         virtual int DropRealTime() = 0;
00089 
00090         virtual void SetParams(UInt64 period, UInt64 computation, UInt64 constraint) // Empty implementation, will only make sense on OSX...
00091         {}
00092 
00093         virtual pthread_t GetThreadID() = 0;
00094 };
00095 
00096 } // end of namespace
00097 
00098 #endif

Generated on Thu Feb 14 11:16:02 2008 for Jackdmp by  doxygen 1.5.1