4.28. Thread::Sequence Class

The Sequence class implements a thread-safe increment-only object.

Table 4.963. Sequence Method Overview

Method

Except?

Description

Sequence::constructor()

N

Creates a new Sequence object.

Sequence::destructor()

N

Destroys the Sequence object.

Sequence::copy()

N

Creates a new Sequence object, not based on the original.

Sequence::next()

N

Atomically increments the counter and returns the last value.

Sequence::getCurrent()

N

Returns the current value of the counter.


4.28.1. Sequence::constructor()

Synopsis

Creates a new Sequence object.

Usage
new Sequence([start])
Example
$seq = new Sequence();

Table 4.964. Arguments for Sequence::constructor()

Argument

Type

Description

[start]

Integer

Optional start number for the sequence (default = 0).


Table 4.965. Return Values for Sequence::constructor()

Return Type

Description

Sequence Object

The new object created.


4.28.2. Sequence::destructor()

Synopsis

Destroys the object.

Usage
delete lvalue
Example
delete $seq;

4.28.3. Sequence::copy()

Synopsis

Creates a new Sequence object, not based on the original.

Usage
Sequence::copy()
Example
$new_seq = $seq.copy();

Table 4.966. Arguments for Sequence::copy()

Argument

Type

Description

n/a

n/a

This method takes no arguments.


Table 4.967. Return Values for Sequence::copy()

Return Type

Description

Sequence Object

A new Sequence object, not based on the original.


4.28.4. Sequence::next()

Synopsis

Atomically increments the counter and returns the last value.

Usage
Sequence::next()
Example
$seq.next();

Table 4.968. Arguments for Sequence::next()

Argument

Type

Description

n/a

n/a

This method takes no arguments.


Table 4.969. Return Values for Sequence::next()

Return Type

Description

Integer

The last value of the sequence.


4.28.5. Sequence::getCurrent()

Synopsis

Returns the current value of the counter.

Usage
Sequence::getCurrent()
Example
$num = $seq.getCurrent();

Table 4.970. Arguments for Sequence::getCurrent()

Argument

Type

Description

n/a

n/a

This method takes no arguments.


Table 4.971. Return Values for Sequence::getCurrent()

Return Type

Description

Integer

The current value of the counter.