![]() |
Main Page
Class Hierarchy
Alphabetical List
Compound List
File List
Compound Members
![]() |
00001 /******************************************************************************** 00002 * * 00003 * Null Mutex - can be used to test mutex handling * 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 FXNULLMUTEX_H 00023 #define FXNULLMUTEX_H 00024 00025 #ifndef FXLOCKABLE_H 00026 #include "FXLockable.h" 00027 #endif 00028 namespace FXEX { 00029 00030 /** 00031 * A null mutex is a mutex, whic provides the API of a mutex, but doesn't provide 00032 * any locking facilities. You would usually use this object during the development 00033 * stage to iron out any design flaws. 00034 * 00035 * The object error checks to make sure you havn't unlocked too many times. It also 00036 * prints the number locks held on destruction. 00037 */ 00038 class FXAPI FXNullMutex : public FXLockable { 00039 00040 private: 00041 // dummy copy constructor and operator= to prevent copying 00042 FXNullMutex(const FXNullMutex&); 00043 FXNullMutex& operator=(const FXNullMutex&); 00044 00045 public: 00046 /// create me a null mutex :-) 00047 FXNullMutex(); 00048 00049 /// lock mutex 00050 void lock() { lock_++; } 00051 00052 /// try to lock the mutex, within some period 00053 FXbool trylock(FXint ms) { return (++lock_)?TRUE:FALSE; } 00054 00055 /// release mutex lock 00056 void unlock(); 00057 00058 /// dtor 00059 ~FXNullMutex(); 00060 }; 00061 00062 } // namespace FXEX 00063 #endif // FXNULLMUTEX_H