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-e72c3f656dc1remotes/trunk
parent
10bdfb1bfe
commit
169a579ea8
|
@ -1436,6 +1436,21 @@ int NamedCounter::dec()
|
|||
#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()
|
||||
{
|
||||
|
|
|
@ -3656,6 +3656,12 @@ public:
|
|||
*/
|
||||
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
|
||||
* @return Value of the counter
|
||||
|
|
Loading…
Reference in New Issue