FirteX-高性能全文索引和检索平台API Documentation |
00001 // 00002 // Copyright(C) 2005--2006 Institute of Computing Tech, Chinese Academy of Sciences. 00003 // All rights reserved. 00004 // This file is part of FirteX (www.firtex.org) 00005 // 00006 // Use of the FirteX is subject to the terms of the software license set forth in 00007 // the LICENSE file included with this software, and also available at 00008 // http://www.firtex.org/license.html 00009 // 00010 // Author : 郭瑞杰(GuoRuijie) 00011 // Email : ruijieguo@software.ict.ac.cn,ruijieguo@gmail.com 00012 // Created : 2005/11/20 00013 // 00014 #ifndef _MUTEX_WIN32_H 00015 #define _MUTEX_WIN32_H 00016 00017 #include "Lockable.h" 00018 //#include "NonCopypable.h" 00019 #include <windows.h> 00020 00021 namespace firtex 00022 { 00023 namespace thread 00024 { 00025 class CMutex : public CLockable//,private CNonCopyable 00026 { 00027 mutable CRITICAL_SECTION C; 00028 public: 00029 CMutex() 00030 { 00031 InitializeCriticalSection(&C); 00032 } 00033 00034 virtual ~CMutex() 00035 { 00036 DeleteCriticalSection(&C); 00037 } 00038 00039 void acquire() 00040 { 00041 EnterCriticalSection(&C); 00042 } 00043 00044 #if(_WIN32_WINNT >= 0x0400) 00045 bool tryAcquire(unsigned long timeout) 00046 { 00047 return (TryEnterCriticalSection(&C)?true:false); 00048 } 00049 #else 00050 bool tryAcquire(unsigned long timeout) 00051 { 00052 return true; 00053 } 00054 #endif 00055 00056 00057 void release() 00058 { 00059 LeaveCriticalSection(&C); 00060 } 00061 }; 00062 00063 } 00064 } 00065 00066 00067 #endif
http://www.firtex.org http://www.sourceforge.net/projects/firtex