4.29. Thread::Sequence Class

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

Table 4.782. Sequence Method Overview

Method

Except?

Description

Sequence::constructor()

Sequence::constructor(softint$start)

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.

intSequence::next()

N

Atomically increments the counter and returns the last value.

intSequence::getCurrent()

N

Returns the current value of the counter.


4.29.1. Sequence::constructor()

Synopsis

Creates a new Sequence object.

Prototype

Sequence::constructor()

Sequence::constructor(softint$start)

Example
my Sequence $seq();

Table 4.783. Arguments for Sequence::constructor()

Argument

Description

[softint$start]

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


4.29.2. Sequence::destructor()

Synopsis

Destroys the object.

Example
delete $seq;

4.29.3. Sequence::copy()

Synopsis

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

Example
my Sequence $new_seq = $seq.copy();

4.29.4. Sequence::next()

Synopsis

Atomically increments the counter and returns the last value.

Prototype

intSequence::next()

Example
$seq.next();

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

Return Type

Description

int

The last value of the sequence.


4.29.5. Sequence::getCurrent()

Synopsis

Returns the current value of the counter.

Prototype

intSequence::getCurrent()

Example
my int $num = $seq.getCurrent();

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

Return Type

Description

int

The current value of the counter.


There are no comments yet

Leave a Comment



?
? ?
?

 
Powered by TalkBack