ARC SDK
Public Member Functions | Protected Member Functions
Arc::IntraProcessCounter Class Reference

A class for counters used by threads within a single process. More...

#include <arc/IntraProcessCounter.h>

Inheritance diagram for Arc::IntraProcessCounter:
Arc::Counter

Public Member Functions

 IntraProcessCounter (int limit, int excess)
 Creates an IntraProcessCounter with specified limit and excess. More...
 
virtual ~IntraProcessCounter ()
 Destructor. More...
 
virtual int getLimit ()
 Returns the current limit of the counter. More...
 
virtual int setLimit (int newLimit)
 Sets the limit of the counter. More...
 
virtual int changeLimit (int amount)
 Changes the limit of the counter. More...
 
virtual int getExcess ()
 Returns the excess limit of the counter. More...
 
virtual int setExcess (int newExcess)
 Sets the excess limit of the counter. More...
 
virtual int changeExcess (int amount)
 Changes the excess limit of the counter. More...
 
virtual int getValue ()
 Returns the current value of the counter. More...
 
virtual CounterTicket reserve (int amount=1, Glib::TimeVal duration=ETERNAL, bool prioritized=false, Glib::TimeVal timeOut=ETERNAL)
 Makes a reservation from the counter. More...
 
- Public Member Functions inherited from Arc::Counter
virtual ~Counter ()
 The destructor. More...
 

Protected Member Functions

virtual void cancel (IDType reservationID)
 Cancellation of a reservation. More...
 
virtual void extend (IDType &reservationID, Glib::TimeVal &expiryTime, Glib::TimeVal duration=ETERNAL)
 Extension of a reservation. More...
 
- Protected Member Functions inherited from Arc::Counter
 Counter ()
 Default constructor. More...
 
Glib::TimeVal getCurrentTime ()
 Get the current time. More...
 
Glib::TimeVal getExpiryTime (Glib::TimeVal duration)
 Computes an expiry time. More...
 
CounterTicket getCounterTicket (Counter::IDType reservationID, Glib::TimeVal expiryTime, Counter *counter)
 A "relay method" for a constructor of the CounterTicket class. More...
 
ExpirationReminder getExpirationReminder (Glib::TimeVal expTime, Counter::IDType resID)
 A "relay method" for the constructor of ExpirationReminder. More...
 

Additional Inherited Members

- Protected Types inherited from Arc::Counter
typedef unsigned long long int IDType
 A typedef of identification numbers for reservation. More...
 

Detailed Description

A class for counters used by threads within a single process.

This is a class for shared among different threads within a single process. See the Counter class for further information about counters and examples of usage.

Constructor & Destructor Documentation

◆ IntraProcessCounter()

Arc::IntraProcessCounter::IntraProcessCounter ( int  limit,
int  excess 
)

Creates an IntraProcessCounter with specified limit and excess.

This constructor creates a counter with the specified limit (amount of resources available for reservation) and excess limit (an extra amount of resources that may be used for prioritized reservations).

Parameters
limitThe limit of the counter.
excessThe excess limit of the counter.

◆ ~IntraProcessCounter()

virtual Arc::IntraProcessCounter::~IntraProcessCounter ( )
virtual

Destructor.

This is the destructor of the IntraProcessCounter class. Does not need to do anything.

Member Function Documentation

◆ cancel()

virtual void Arc::IntraProcessCounter::cancel ( IDType  reservationID)
protectedvirtual

Cancellation of a reservation.

This method cancels a reservation. It is called by the CounterTicket that corresponds to the reservation.

Parameters
reservationIDThe identity number (key) of the reservation to cancel.

Implements Arc::Counter.

◆ changeExcess()

virtual int Arc::IntraProcessCounter::changeExcess ( int  amount)
virtual

Changes the excess limit of the counter.

Changes the excess limit of the counter by adding a certain amount to the current excess limit.

Parameters
amountThe amount by which to change the excess limit.
Returns
The new excess limit.

Implements Arc::Counter.

◆ changeLimit()

virtual int Arc::IntraProcessCounter::changeLimit ( int  amount)
virtual

Changes the limit of the counter.

Changes the limit of the counter by adding a certain amount to the current limit.

Parameters
amountThe amount by which to change the limit.
Returns
The new limit.

Implements Arc::Counter.

◆ extend()

virtual void Arc::IntraProcessCounter::extend ( IDType reservationID,
Glib::TimeVal &  expiryTime,
Glib::TimeVal  duration = ETERNAL 
)
protectedvirtual

Extension of a reservation.

This method extends a reservation. It is called by the CounterTicket that corresponds to the reservation.

Parameters
reservationIDUsed for input as well as output. Contains the identification number of the original reservation on entry and the new identification number of the extended reservation on exit.
expiryTimeUsed for input as well as output. Contains the expiry time of the original reservation on entry and the new expiry time of the extended reservation on exit.
durationThe time by which to extend the reservation. The new expiration time is computed based on the current time, NOT the previous expiration time.

Implements Arc::Counter.

◆ getExcess()

virtual int Arc::IntraProcessCounter::getExcess ( )
virtual

Returns the excess limit of the counter.

Returns the excess limit of the counter, i.e. by how much the usual limit may be exceeded by prioritized reservations.

Returns
The excess limit.

Implements Arc::Counter.

◆ getLimit()

virtual int Arc::IntraProcessCounter::getLimit ( )
virtual

Returns the current limit of the counter.

This method returns the current limit of the counter, i.e. how many units can be reserved simultaneously by different threads without claiming high priority.

Returns
The current limit of the counter.

Implements Arc::Counter.

◆ getValue()

virtual int Arc::IntraProcessCounter::getValue ( )
virtual

Returns the current value of the counter.

Returns the current value of the counter, i.e. the number of unreserved units. Initially, the value is equal to the limit of the counter. When a reservation is made, the the value is decreased. Normally, the value should never be negative, but this may happen if there are prioritized reservations. It can also happen if the limit is decreased after some reservations have been made, since reservations are never revoked.

Returns
The current value of the counter.

Implements Arc::Counter.

◆ reserve()

virtual CounterTicket Arc::IntraProcessCounter::reserve ( int  amount = 1,
Glib::TimeVal  duration = ETERNAL,
bool  prioritized = false,
Glib::TimeVal  timeOut = ETERNAL 
)
virtual

Makes a reservation from the counter.

This method makes a reservation from the counter. If the current value of the counter is too low to allow for the reservation, the method blocks until the reservation is possible or times out.

Parameters
amountThe amount to reserve, default value is 1.
durationThe duration of a self expiring reservation, default is that it lasts forever.
prioritizedWhether this reservation is prioritized and thus allowed to use the excess limit.
timeOutThe maximum time to block if the value of the counter is too low, default is to allow "eternal" blocking.
Returns
A CounterTicket that can be queried about the status of the reservation as well as for cancellations and extensions.

Implements Arc::Counter.

◆ setExcess()

virtual int Arc::IntraProcessCounter::setExcess ( int  newExcess)
virtual

Sets the excess limit of the counter.

This method sets a new excess limit for the counter.

Parameters
newExcessThe new excess limit, an absolute number.
Returns
The new excess limit.

Implements Arc::Counter.

◆ setLimit()

virtual int Arc::IntraProcessCounter::setLimit ( int  newLimit)
virtual

Sets the limit of the counter.

This method sets a new limit for the counter.

Parameters
newLimitThe new limit, an absolute number.
Returns
The new limit.

Implements Arc::Counter.


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