Back to index
A class for "tickets" that correspond to counter reservations. More...
|The default constructor. |
|Returns the validity of a CounterTicket. |
|void||extend (Glib::TimeVal duration)|
|Extends a reservation. |
|Cancels a resrvation. |
|CounterTicket (Counter::IDType reservationID, Glib::TimeVal expiryTime, Counter *counter)|
|A private constructor. |
|The identification number of the corresponding reservation. |
|The expiry time of the corresponding reservation. |
|A pointer to the Counter from which the reservation was made. |
|The Counter class needs to be a friend. |
A class for "tickets" that correspond to counter reservations.
This is a class for reservation tickets. When a reservation is made from a Counter, a ReservationTicket is returned. This ticket can then be queried about the validity of a reservation. It can also be used for cancelation and extension of reservations.
Typical usage is:
// Declare a counter. Replace XYZ by some appropriate kind of // counter and provide required parameters. Unit is MB. XYZCounter memory(...); ... // Make a reservation of memory for 2000000 doubles. CounterTicket tick = memory.reserve(2*sizeof(double)); // Use the memory. double* A=new double; doSomething(A); delete A; // Cancel the reservation. tick.cancel();
The default constructor.
A private constructor.
This constructor creates an CounterTicket containing the specified expiry time and identity number of a reservation besides a pointer to the counter from which the reservation was made. In order to prevent unintended use, it is private. Because the Counter class must be able to use this constructor, it is declared to be a friend of this class.
|reservationID||The identification number of the reservation.|
|expiryTime||The expiry time of the reservation.|
|counter||A pointer to the counter from which the reservation was made.|
Cancels a resrvation.
This method is called to cancel a reservation. It may be called also for self-expiring reservations, which will then be cancelled before they were originally planned to expire.
Extends a reservation.
Extends a self-expiring reservation. In order to succeed the extension should be made before the previous reservation expires.
|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.|
Returns the validity of a CounterTicket.
|friend class Counter