40 lines
880 B
C++
40 lines
880 B
C++
//----------------------------------------------------------------------------
|
|
//
|
|
// Copyright (C) Intel Corporation, 2006 - 2007.
|
|
//
|
|
// File: GuardedCounter.h
|
|
//
|
|
// Contents: A guarded counter.
|
|
//
|
|
// Notes:
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
#ifndef _GuardedCounter_h__
|
|
#define _GuardedCounter_h__
|
|
|
|
#include <ace/Thread_Mutex.h>
|
|
#include <ace/Basic_Types.h>
|
|
|
|
class GuardedCounter
|
|
{
|
|
public:
|
|
GuardedCounter(void);
|
|
GuardedCounter(ACE_UINT32 MaxVal);
|
|
GuardedCounter(ACE_UINT32 InitVal,ACE_UINT32 MaxVal);
|
|
~GuardedCounter(void);
|
|
void Increment();
|
|
void Decrement();
|
|
ACE_UINT32 GetCounterValue();
|
|
int TryIncrementCheckMax();
|
|
int IncrementCheckMax();
|
|
void SetMaxValue(ACE_UINT32 val);
|
|
private:
|
|
|
|
ACE_UINT32 _counter;
|
|
ACE_UINT32 _MaxValue;
|
|
ACE_Thread_Mutex _counter_mutex;
|
|
|
|
};
|
|
#endif //_GuardedCounter_h__
|