Back to index

nordugrid-arc-nox  1.1.0~rc6
Public Member Functions | Private Member Functions | Private Attributes | Friends
Arc::CounterTicket Class Reference

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

#include <Counter.h>

Collaboration diagram for Arc::CounterTicket:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 CounterTicket ()
 The default constructor.
bool isValid ()
 Returns the validity of a CounterTicket.
void extend (Glib::TimeVal duration)
 Extends a reservation.
void cancel ()
 Cancels a resrvation.

Private Member Functions

 CounterTicket (Counter::IDType reservationID, Glib::TimeVal expiryTime, Counter *counter)
 A private constructor.

Private Attributes

Counter::IDType reservationID
 The identification number of the corresponding reservation.
Glib::TimeVal expiryTime
 The expiry time of the corresponding reservation.
Countercounter
 A pointer to the Counter from which the reservation was made.

Friends

class Counter
 The Counter class needs to be a friend.

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();

Definition at line 343 of file Counter.h.


Constructor & Destructor Documentation

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.

Definition at line 60 of file Counter.cpp.

    : reservationID(0),
      expiryTime(HISTORIC),
      counter(0) {
    // Nothing else needs to be done.
  }
Arc::CounterTicket::CounterTicket ( Counter::IDType  reservationID,
Glib::TimeVal  expiryTime,
Counter counter 
) [private]

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.

Parameters:
reservationIDThe identification number of the reservation.
expiryTimeThe expiry time of the reservation.
counterA pointer to the counter from which the reservation was made.

Definition at line 67 of file Counter.cpp.

    : reservationID(reservationID),
      expiryTime(expiryTime),
      counter(counter) {
    // Nothing else needs to be done.
  }

Member Function Documentation

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.

Definition at line 84 of file Counter.cpp.

Here is the call graph for this function:

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:
durationThe time by which to extend the reservation. The new expiration time is computed based on the current time, NOT the previous expiration time.

Definition at line 80 of file Counter.cpp.

Here is the call graph for this function:

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.

Definition at line 76 of file Counter.cpp.

                              {
    return expiryTime > counter->getCurrentTime();
  }

Here is the call graph for this function:


Friends And Related Function Documentation

friend class Counter [friend]

The Counter class needs to be a friend.

Definition at line 408 of file Counter.h.


Member Data Documentation

A pointer to the Counter from which the reservation was made.

Definition at line 405 of file Counter.h.

Glib::TimeVal Arc::CounterTicket::expiryTime [private]

The expiry time of the corresponding reservation.

Definition at line 402 of file Counter.h.

The identification number of the corresponding reservation.

Definition at line 399 of file Counter.h.


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