JackPosixThread.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 __JackPosixThread__
00022 #define __JackPosixThread__
00023 
00024 #include "JackThread.h"
00025 #include <pthread.h>
00026 
00027 namespace Jack
00028 {
00029 
00030 /* use 512KB stack per thread - the default is way too high to be feasible 
00031  * with mlockall() on many systems */
00032 #define THREAD_STACK 524288
00033 
00038 class JackPosixThread : public JackThread
00039 {
00040 
00041     protected:
00042 
00043         pthread_t fThread;
00044         static void* ThreadHandler(void* arg);
00045 
00046     public:
00047 
00048         JackPosixThread(JackRunnableInterface* runnable, bool real_time, int priority, int cancellation)
00049                 : JackThread(runnable, priority, real_time, cancellation), fThread((pthread_t)NULL)
00050         {}
00051         JackPosixThread(JackRunnableInterface* runnable)
00052                 : JackThread(runnable, 0, false, PTHREAD_CANCEL_DEFERRED), fThread((pthread_t)NULL)
00053         {}
00054         JackPosixThread(JackRunnableInterface* runnable, int cancellation)
00055                 : JackThread(runnable, 0, false, cancellation), fThread((pthread_t)NULL)
00056         {}
00057 
00058         virtual ~JackPosixThread()
00059         {}
00060 
00061         virtual int Start();
00062         virtual int StartSync();
00063         virtual int Kill();
00064         virtual int Stop();
00065                 virtual void Terminate();
00066 
00067         virtual int AcquireRealTime();
00068         virtual int AcquireRealTime(int priority);
00069         virtual int DropRealTime();
00070 
00071         pthread_t GetThreadID();
00072                 
00073                 static int AcquireRealTimeImp(pthread_t thread, int priority);
00074                 static int DropRealTimeImp(pthread_t thread);
00075                 static int StartImp(pthread_t* thread, int priority, int realtime, void*(*start_routine)(void*), void* arg);
00076 
00077 };
00078 
00079 } // end of namespace
00080 
00081 
00082 #endif

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