ARC SDK
Public Member Functions | Friends
Arc::CounterTicket Class Reference

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

#include <arc/Counter.h>

Public Member Functions

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

Friends

class Counter
 The Counter class needs to be a friend. More...
 

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 cancellation 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

◆ CounterTicket()

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

◆ cancel()

void Arc::CounterTicket::cancel ( )

Cancels a reservation.

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.

◆ extend()

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.

◆ isValid()

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.

Friends And Related Function Documentation

◆ Counter

friend class Counter
friend

The Counter class needs to be a friend.


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