Implemented NamedCounter method that allows adding a specific value to the counter.
git-svn-id: http://yate.null.ro/svn/yate/trunk@6541 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
parent
10bdfb1bfe
commit
169a579ea8
|
@ -1436,6 +1436,21 @@ int NamedCounter::dec()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int NamedCounter::add(int val)
|
||||||
|
{
|
||||||
|
#ifdef ATOMIC_OPS
|
||||||
|
#ifdef _WINDOWS
|
||||||
|
return InterlockedExchangeAdd((LONG*)&m_count,(LONG)val);
|
||||||
|
#else
|
||||||
|
return __sync_add_and_fetch(&m_count,val);
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
Lock lock(m_mutex);
|
||||||
|
m_count += val;
|
||||||
|
return m_count;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void SysUsage::init()
|
void SysUsage::init()
|
||||||
{
|
{
|
||||||
|
|
|
@ -3656,6 +3656,12 @@ public:
|
||||||
*/
|
*/
|
||||||
int dec();
|
int dec();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a specific value to the counter
|
||||||
|
* @param val Value to add
|
||||||
|
*/
|
||||||
|
int add(int val);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the current value of the counter
|
* Get the current value of the counter
|
||||||
* @return Value of the counter
|
* @return Value of the counter
|
||||||
|
|
Loading…
Reference in New Issue