osxmutexpeer.cpp
来自「这是VCF框架的代码」· C++ 代码 · 共 75 行
CPP
75 行
//OSXMutexPeer.cpp/*Copyright 2000-2004 The VCF Project.Please see License.txt in the top level directorywhere you installed the VCF.*/#include "vcf/FoundationKit/FoundationKit.h"#include "vcf/FoundationKit/FoundationKitPrivate.h"#include "vcf/FoundationKit/ThreadException.h"using namespace VCF;OSXMutex::OSXMutex(): mutex_(NULL){ MPLibraryIsLoaded(); OSStatus err = MPCreateCriticalRegion( &mutex_ ); if ( (err != noErr) || (mutex_ == kInvalidID) ) { throw ThreadException( MAKE_ERROR_MSG_2("MPCreateCriticalRegion failed or returned an invalid critical region ID") ); }}OSXMutex::~OSXMutex(){ OSStatus err = MPDeleteCriticalRegion( mutex_ ); VCF_ASSERT(err == noErr);}bool OSXMutex::lock( uint32 timeoutInMilliseconds ){ Duration timeout = kDurationMillisecond * timeoutInMilliseconds; OSStatus err = MPEnterCriticalRegion( mutex_, timeout ); return (err == noErr) ? true : false;}bool OSXMutex::lock(){ OSStatus err = MPEnterCriticalRegion( mutex_, kDurationForever ); return (err == noErr) ? true : false;}bool OSXMutex::unlock(){ OSStatus err = MPExitCriticalRegion( mutex_ ); return (err == noErr) ? true : false;}/***CVS Log info*$Log$*Revision 1.3 2005/07/09 23:15:04 ddiego*merging in changes from devmain-0-6-7 branch.**Revision 1.2.4.1 2005/05/08 19:55:32 ddiego*osx updates, not yet functional.**Revision 1.2 2004/08/07 02:49:14 ddiego*merged in the devmain-0-6-5 branch to stable**Revision 1.1.2.6 2004/06/06 07:05:32 marcelloptr*changed macros, text reformatting, copyright sections**/
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?