Jack2 1.9.10

JackPosixMutex.h

00001 /*
00002  Copyright (C) 2006 Grame
00003 
00004  This library is free software; you can redistribute it and/or
00005  modify it under the terms of the GNU Lesser General Public
00006  License as published by the Free Software Foundation; either
00007  version 2.1 of the License, or (at your option) any later version.
00008 
00009  This library 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 GNU
00012  Lesser General Public License for more details.
00013 
00014  You should have received a copy of the GNU Lesser General Public
00015  License along with this library; if not, write to the Free Software
00016  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017 
00018  Grame Research Laboratory, 9 rue du Garet, 69001 Lyon - France
00019  grame@grame.fr
00020 */
00021 
00022 #ifndef __JackPosixMutex__
00023 #define __JackPosixMutex__
00024 
00025 #include "JackException.h"
00026 #include "JackCompilerDeps.h"
00027 
00028 #include <pthread.h>
00029 #include <stdio.h>
00030 #include <assert.h>
00031 
00032 namespace Jack
00033 {
00038 class SERVER_EXPORT JackBasePosixMutex
00039 {
00040 
00041     protected:
00042 
00043         pthread_mutex_t fMutex;
00044         pthread_t fOwner;
00045 
00046     public:
00047 
00048         JackBasePosixMutex(const char* name = NULL);
00049         virtual ~JackBasePosixMutex();
00050 
00051         bool Lock();
00052         bool Trylock();
00053         bool Unlock();
00054 
00055 };
00056 
00057 class SERVER_EXPORT JackPosixMutex
00058 {
00059     protected:
00060 
00061         pthread_mutex_t fMutex;
00062 
00063     public:
00064 
00065         JackPosixMutex(const char* name = NULL);
00066         virtual ~JackPosixMutex();
00067 
00068         bool Lock();
00069         bool Trylock();
00070         bool Unlock();
00071 };
00072 
00073 } // namespace
00074 
00075 #endif