www.pudn.com > DVBPlayer.rar > mytex.cpp, change:2004-07-06,size:592b


 
#include "stdafx.h" 
#include "mutex.h" 
 
 
Mutex:: 
Mutex(bool createOwned) 
{ 
	m_mutex = CreateMutex(	NULL, 
		createOwned, 
		NULL); 
}	 
 
Mutex:: 
~Mutex() 
{ 
	CloseHandle(m_mutex); 
} 
 
 
bool  
Mutex:: 
Acquire(unsigned long timeout) 
{ 
	bool result = false; 
	 
	switch(WaitForSingleObject(m_mutex, timeout)) 
	{ 
	case WAIT_ABANDONED: 
	case WAIT_OBJECT_0: 
		{ 
			result = true; 
			break; 
		} 
		 
	case WAIT_TIMEOUT: 
	case WAIT_FAILED: 
		{ 
			 
			result = false; 
			break; 
		} 
	} 
	 
	return result; 
} 
 
void  
Mutex:: 
Release() 
{ 
	ReleaseMutex(m_mutex); 
}