(Latest Version)

morpheus.utils.atomic_integer.AtomicInteger

class AtomicInteger(value=0)[source]

Bases: <a href="https://docs.python.org/3/library/functions.html#object">object</a>

Simple atomic integer from https://stackoverflow.com/a/48433648/634820

Parameters
_valueint

Initial value, defaults to 0.

Attributes
<a href="#morpheus.utils.atomic_integer.AtomicInteger.value">value</a>

Get value.

Methods

<a href="#morpheus.utils.atomic_integer.AtomicInteger.dec">dec</a>([d])

Decrements and returns new value.

<a href="#morpheus.utils.atomic_integer.AtomicInteger.get_and_inc">get_and_inc</a>([d])

Gets the current value, returns it, and increments.

<a href="#morpheus.utils.atomic_integer.AtomicInteger.inc">inc</a>([d])

Increments and returns new value.

dec(d=1)[source]

Decrements and returns new value.

Parameters
dint, optional

Value to decrement by, default 1.

Returns
int

Decremented value.

get_and_inc(d=1)[source]

Gets the current value, returns it, and increments. Different from <a href="#morpheus.utils.atomic_integer.AtomicInteger.inc">inc()</a> which increments, then returns.

Parameters
dint, optional

How much to increment, by default 1.

Returns
int

Incremented value.

inc(d=1)[source]

Increments and returns new value.

Parameters
dint, optional

Value to increment by, default 1.

Returns
int

Incremented value.

property value

Get value.

Returns
int

Current value.

© Copyright 2023, NVIDIA. Last updated on Apr 11, 2023.