|
// By David S. Bakin (davidbak@gmail.com)
// Copyright @ 2009 David S. Bakin
// This work licensed under The Code Project Open License (CPOL) 1.02
#include "stdafx.h"
#include "Locks.h"
CLockCritSec::CLockCritSec()
{
BOOL b = ::InitializeCriticalSectionAndSpinCount(&critsec_, 4000);
if (b == 0)
{
DWORD err = ::GetLastError();
// Error: can't initialize critical section - should never happen!
assert(1);
}
}
CLockCritSec::~CLockCritSec()
{
::DeleteCriticalSection(&critsec_);
}
void CLockCritSec::Lock()
{
::EnterCriticalSection(&critsec_);
}
void CLockCritSec::Unlock()
{
::LeaveCriticalSection(&critsec_);
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I've been programming for 35 years and I'm still learning new things. My major interests recently are programming models and methods for concurrency, applications of functional programming, and doing interesting things with Mathematica.