| Qore Programming Language Reference Manual 2.2.0

Loading...
Searching...
No Matches
Public Member Functions | List of all members
Qore::Thread::Sequence Class Reference

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

`#include <QC_Sequence.dox.h>`

## Public Member Functions
| constructor ()
| Creates a new Sequence object.
| constructor (softint start)
| Creates a new Sequence object with a starting value.
| copy ()
| Creates a new Sequence object, not based on the original.
int | getCurrent ()
| Returns the current value of the sequence.
int | next ()
| Atomically increments the sequence value and returns the last value.

## Detailed Description

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

This class does not block therefore is not tagged with Qore::PO_NO_THREAD_CLASSES

## Member Function Documentation

## ◆ constructor() [1/2]

Qore::Thread::Sequence::constructor | ( |  | ) |

Creates a new Sequence object.

Example:
  Sequence seq();

## ◆ constructor() [2/2]

Qore::Thread::Sequence::constructor | ( | softint | start | ) |

Creates a new Sequence object with a starting value.

Example:
  Sequence seq(20);

## ◆ copy()

Qore::Thread::Sequence::copy | ( |  | ) |

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

Example:
  Sequence s2 = seq.copy();

## ◆ getCurrent()

int Qore::Thread::Sequence::getCurrent | ( |  | ) |

Returns the current value of the sequence.

Returns
  current value of the sequence

Code Flags:
  CONSTANT

Example:
  int v = seq.getCurrent();

## ◆ next()

int Qore::Thread::Sequence::next | ( |  | ) |

Atomically increments the sequence value and returns the last value.

Returns
  the last value of the sequence

Example:
  int next = seq.next();