Arc::CounterTicket Class Reference

A class for "tickets" that correspond to counter reservations. More...

#include <Counter.h>

Public Member Functions

 CounterTicket ()
bool isValid ()
void extend (Glib::TimeVal duration)
void cancel ()

Friends

class Counter

Detailed Description

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[2000000];
     doSomething(A);
     delete[] A;
     // Cancel the reservation.
     tick.cancel();

Constructor & Destructor Documentation

Arc::CounterTicket::CounterTicket (  ) 

The default constructor.

This is the default constructor. It creates a CounterTicket that is not valid. The ticket object that is created can later be assigned a ticket that is returned by the reserve() method of a Counter.


Member Function Documentation

void Arc::CounterTicket::cancel (  ) 

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.

void Arc::CounterTicket::extend ( Glib::TimeVal  duration  ) 

Extends a reservation.

Extends a self-expiring reservation. In order to succeed the extension should be made before the previous reservation expires.

Parameters:
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.
bool Arc::CounterTicket::isValid (  ) 

Returns the validity of a CounterTicket.

This method checks whether a CounterTicket is valid. The ticket was probably returned earlier by the reserve() method of a Counter but the corresponding reservation may have expired.

Returns:
The validity of the ticket.

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