// Mutex.h: interface for the CMutex class.
//
//////////////////////////////////////////////////////////////////////
//========================================================================
// Class Name	: CMutex
// Purpose		: 
// Autor		: Richard Chuang
// Email		: 
// Description	: 
// Reference    : 
// Copyright    : Copyright (c) 2000-2007 Davicom Inc.  All rights reserved.
// -----------------------------------------------------------------------
// Version		: 1.0.0.0
// Update       : 2007-10-23
// Modified		: Richard Chung
// Description	: 
// -----------------------------------------------------------------------
// How to use: 
//  
#if !defined(_DAVICOM_MUTEX_H_)
#define _DAVICOM_MUTEX_H_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "stdafx.h"

#define	WAIT_FOREVER	((DWORD)-1)
//#ifdef	IMPL_NO_CRITICAL_SECTION
//#error no critical section
#define IMPL_NO_CRITICAL_SECTION 1

class CMutex  
{
public:
	CMutex();
	virtual ~CMutex();
	int	TryLock(void);
	int	Lock(DWORD uMicroSeconds=WAIT_FOREVER, DWORD uMicroPeriod=1000);
	void Release(void);

protected:

#ifdef	IMPL_NO_CRITICAL_SECTION
	NDIS_SPIN_LOCK		m_SpinLock;
	int					m_nValue;
#else
	CRITICAL_SECTION	m_Critical;
#endif
};

#endif // !defined(_DAVICOM_MUTEX_H_)
