Click
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
atomic_uint64_t Class Reference

A 64-bit integer with support for atomic operations. More...

#include <atomic.hh>

Public Member Functions

uint64_t value () const
 Return the value.
 
uint64_t nonatomic_value () const
 Return the value.
 
 operator uint64_t () const
 Return the value.
 
atomic_uint64_t & operator= (uint64_t x)
 Set the value to x.
 
atomic_uint64_t & operator+= (int64_t delta)
 Atomically add delta to the value.
 
atomic_uint64_t & operator-= (int64_t delta)
 Atomically subtract delta from the value.
 
void nonatomic_inc ()
 Increment the value.
 
void operator++ ()
 Atomically increment the value.
 
void operator++ (int)
 Atomically increment the value.
 
void nonatomic_dec ()
 Decrement the value.
 
void operator-- ()
 Atomically decrement the value.
 
void operator-- (int)
 Atomically decrement the value.
 
uint64_t compare_swap (uint64_t expected, uint64_t desired) CLICK_BUILTINS_DEPRECATED
 
uint64_t fetch_and_add (uint64_t delta)
 Perform a compare-and-swap operation.
 

Static Public Member Functions

static void add (volatile uint64_t &x, uint64_t delta)
 Atomically increment value x.
 
static uint64_t compare_swap (volatile uint64_t &x, uint64_t expected, uint64_t desired) CLICK_BUILTINS_DEPRECATED
 
static bool use_builtins ()
 

Detailed Description

A 64-bit integer with support for atomic operations.

The atomic_uint64_t class represents a 64-bit integer, with support for atomic operations. The +=, -=, &=, |=, ++, and – operations are implemented using atomic instructions. There are also atomic swap(), fetch_and_add(), dec_and_test(), and compare_swap() operations.

Because of some issues with compiler implementations, atomic_uint64_t has no explicit constructor; to set an atomic_uint64_t to a value, use operator=.

The atomic_uint64_t only provides true atomic semantics when that has been implemented. It has been implemented in the Linux kernel, and at userlevel (when –enable-multithread has been defined) for x86 machines. In other situations, it's not truly atomic (because it doesn't need to be).

Member Function Documentation

◆ value()

uint64_t atomic_uint64_t::value ( ) const
inline

Return the value.

◆ nonatomic_value()

uint64_t atomic_uint64_t::nonatomic_value ( ) const
inline

Return the value.

◆ operator uint64_t()

atomic_uint64_t::operator uint64_t ( ) const
inline

Return the value.

◆ operator=()

atomic_uint64_t & atomic_uint64_t::operator= ( uint64_t  x)
inline

Set the value to x.

◆ operator+=()

atomic_uint64_t & atomic_uint64_t::operator+= ( int64_t  delta)
inline

Atomically add delta to the value.

◆ operator-=()

atomic_uint64_t & atomic_uint64_t::operator-= ( int64_t  delta)
inline

Atomically subtract delta from the value.

◆ nonatomic_inc()

void atomic_uint64_t::nonatomic_inc ( )
inline

Increment the value.

◆ operator++() [1/2]

void atomic_uint64_t::operator++ ( )
inline

Atomically increment the value.

◆ operator++() [2/2]

void atomic_uint64_t::operator++ ( int  )
inline

Atomically increment the value.

◆ nonatomic_dec()

void atomic_uint64_t::nonatomic_dec ( )
inline

Decrement the value.

◆ operator--() [1/2]

void atomic_uint64_t::operator-- ( )
inline

Atomically decrement the value.

◆ operator--() [2/2]

void atomic_uint64_t::operator-- ( int  )
inline

Atomically decrement the value.

◆ fetch_and_add()

uint64_t atomic_uint64_t::fetch_and_add ( uint64_t  delta)
inline

Perform a compare-and-swap operation.

Parameters
xvalue
expectedtest value
desirednew value
Returns
The actual old value. If it equaled expected, x has been set to desired.

Behaves like this, but in one atomic step:

uint62_t actual = x;
if (x == expected)
x = desired;
return actual;

Also acts as a memory barrier.

Atomically add delta to the value, returning the old value.

Behaves like this, but in one atomic step:

uint32_t old_value = value();
*this += delta;
return old_value;
uint64_t value() const
Return the value.
Definition atomic.hh:817

◆ add()

void atomic_uint64_t::add ( volatile uint64_t &  x,
uint64_t  delta 
)
inlinestatic

Atomically increment value x.


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