![]() |
Main Page
Class Hierarchy
Alphabetical List
Compound List
File List
Compound Members
![]() |
00001 /******************************************************************************** 00002 * * 00003 * Fast Mutex (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 FXFASTMUTEX_H 00023 #define FXFASTMUTEX_H 00024 00025 #ifndef FXLOCKABLE_H 00026 #include "FXLockable.h" 00027 #endif 00028 namespace FXEX { 00029 00030 /** 00031 * A Fast mutex doesn't implement mutex recursion or error checking 00032 * ie you cant lock it more than once, otherwise it simply blocks 00033 * which can sometimes be useful 00034 * 00035 * Note: this class doesn't store any internal state, such that, 00036 * if you lock it, it is up to you to unlock it. 00037 */ 00038 class FXAPI FXFastMutex : public FXLockable { 00039 00040 private: 00041 FXThreadMutex mutexHandle; 00042 00043 private: 00044 // dummy copy constructor and operator= to prevent copying 00045 FXFastMutex(const FXFastMutex&); 00046 FXFastMutex& operator=(const FXFastMutex&); 00047 00048 public: 00049 /// create me a fast mutex :-) 00050 FXFastMutex(); 00051 00052 /// lock mutex 00053 void lock(); 00054 00055 /// for a fastlock, trylock fails when we cant lock immediately (ie ms is ignored) 00056 FXbool trylock(FXuint ms); 00057 00058 /// release mutex lock 00059 void unlock(); 00060 00061 /// dtor 00062 ~FXFastMutex(); 00063 }; 00064 00065 } // namespace FXEX 00066 #endif // FXFASTMUTEX_H