Arc::IntraProcessCounter Class Reference

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

#include <IntraProcessCounter.h>

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

Public Member Functions

 IntraProcessCounter (int limit, int excess)
virtual ~IntraProcessCounter ()
virtual int getLimit ()
virtual int setLimit (int newLimit)
virtual int changeLimit (int amount)
virtual int getExcess ()
virtual int setExcess (int newExcess)
virtual int changeExcess (int amount)
virtual int getValue ()
virtual CounterTicket reserve (int amount=1, Glib::TimeVal duration=ETERNAL, bool prioritized=false, Glib::TimeVal timeOut=ETERNAL)

Protected Member Functions

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

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

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:
limit The limit of the counter.
excess The excess limit of the counter.
virtual Arc::IntraProcessCounter::~IntraProcessCounter (  )  [virtual]

Destructor.

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


Member Function Documentation

virtual void Arc::IntraProcessCounter::cancel ( IDType  reservationID  )  [protected, virtual]

Cancellation of a reservation.

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

Parameters:
reservationID The identity number (key) of the reservation to cancel.

Implements Arc::Counter.

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:
amount The amount by which to change the excess limit.
Returns:
The new excess limit.

Implements Arc::Counter.

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:
amount The amount by which to change the limit.
Returns:
The new limit.

Implements Arc::Counter.

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

Extension of a reservation.

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

Parameters:
reservationID Used 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.
expiryTime Used 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.
duration The 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.

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.

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.

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.

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:
amount The amount to reserve, default value is 1.
duration The duration of a self expiring reservation, default is that it lasts forever.
prioritized Whether this reservation is prioritized and thus allowed to use the excess limit.
timeOut The 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.

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:
newExcess The new excess limit, an absolute number.
Returns:
The new excess limit.

Implements Arc::Counter.

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

Sets the limit of the counter.

This method sets a new limit for the counter.

Parameters:
newLimit The new limit, an absolute number.
Returns:
The new limit.

Implements Arc::Counter.


The documentation for this class was generated from the following file:
Generated on Wed Jun 27 11:54:21 2012 for Hosting Environment (Daemon) by  doxygen 1.6.3