ARC SDK
Public Member Functions
Arc::SimpleCounter Class Reference

Thread-safe counter with capability to wait for zero value. More...

#include <arc/Thread.h>

Public Member Functions

virtual int inc (void)
 Increment value of counter. More...
 
virtual int dec (void)
 Decrement value of counter. More...
 
virtual int get (void) const
 
virtual int set (int v)
 Set value of counter. More...
 
virtual void wait (void) const
 Wait for zero condition. More...
 
virtual bool wait (int t) const
 Wait for zero condition no longer than t milliseconds. More...
 
virtual void forceReset (void)
 This method is meant to be used only after fork. More...
 

Detailed Description

Thread-safe counter with capability to wait for zero value.

It is extendible through re-implementation of virtual methods.

Member Function Documentation

◆ dec()

virtual int Arc::SimpleCounter::dec ( void  )
virtual

Decrement value of counter.

Returns
new value. Does not go below 0 value.

◆ forceReset()

virtual void Arc::SimpleCounter::forceReset ( void  )
inlinevirtual

This method is meant to be used only after fork.

It resets state of all internal locks and variables.

◆ get()

virtual int Arc::SimpleCounter::get ( void  ) const
virtual
Returns
current value of counter.

◆ inc()

virtual int Arc::SimpleCounter::inc ( void  )
virtual

Increment value of counter.

Returns
new value.

◆ set()

virtual int Arc::SimpleCounter::set ( int  v)
virtual

Set value of counter.

Returns
new value.

◆ wait() [1/2]

virtual void Arc::SimpleCounter::wait ( void  ) const
virtual

Wait for zero condition.

◆ wait() [2/2]

virtual bool Arc::SimpleCounter::wait ( int  t) const
virtual

Wait for zero condition no longer than t milliseconds.

If t is negative - wait forever.

Returns
false if timeout occurred.

The documentation for this class was generated from the following file: