![]() |
Main Page
Class Hierarchy
Alphabetical List
Compound List
File List
Compound Members
![]() |
00001 /******************************************************************************** 00002 * * 00003 * Mutal exclusion object (required for threads) * 00004 * * 00005 ********************************************************************************* 00006 * Copyright (C) 2003 by Mathew Robertson. All Rights Reserved. * 00007 ********************************************************************************* 00008 * This library is free software; you can redistribute it and/or * 00009 * modify it under the terms of the GNU Lesser General Public * 00010 * License as published by the Free Software Foundation; either * 00011 * version 2.1 of the License, or (at your option) any later version. * 00012 * * 00013 * This library is distributed in the hope that it will be useful, * 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00016 * Lesser General Public License for more details. * 00017 * * 00018 * You should have received a copy of the GNU Lesser General Public * 00019 * License along with this library; if not, write to the Free Software * 00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * 00021 ********************************************************************************/ 00022 #ifndef FXMUTEX_H 00023 #define FXMUTEX_H 00024 00025 #ifndef FXLOCKABLE_H 00026 #include "FXLockable.h" 00027 #endif 00028 namespace FXEX { 00029 class FXCondition; 00030 00031 /** 00032 * Recursive mutual exclusion object. 00033 * Unlocks on destruction 00034 */ 00035 class FXAPI FXMutex : public FXLockable { 00036 friend class FXCondition; 00037 00038 private: 00039 FXThreadMutex mutexHandle; 00040 00041 private: 00042 // dummy copy constructor and operator= to prevent copying 00043 FXMutex(const FXMutex&); 00044 FXMutex& operator=(const FXMutex&); 00045 00046 public: 00047 /// create me a mutex :-) 00048 FXMutex(); 00049 00050 /// lock mutex 00051 void lock(); 00052 00053 /// try to lock the mutex, within some period 00054 FXbool trylock(FXuint ms); 00055 00056 /// release mutex lock 00057 void unlock(); 00058 00059 /// dtor 00060 virtual ~FXMutex(); 00061 }; 00062 00063 } // namespace FXEX 00064 #endif // FXMUTEX_H