hamcast  Version 0.7
Classes | Functions
hamcast::util Namespace Reference

Classes

class  buffered_sink
 
class  buffered_source
 
struct  closeable
 
class  comparable
 
class  const_buffer
 
class  deserializer
 
class  future
 
class  id_generator
 
struct  mock_mutex
 
class  read_buffer
 
class  serializer
 
class  single_reader_queue
 
struct  sink
 
struct  source
 
struct  unit
 
class  write_buffer
 

Functions

template<typename T >
bool atomic_cas (volatile T **ptr, T *ptr_expected, T *ptr_new)
 
boost::int32_t add_and_fetch (volatile boost::int32_t *ptr, boost::int32_t value)
 

Detailed Description

This namespace contains utility classes.

Function Documentation

boost::int32_t hamcast::util::add_and_fetch ( volatile boost::int32_t *  ptr,
boost::int32_t  value 
)

Atomically increase the content of ptr by value and return the new content of ptr.

Parameters
ptrMemory location of the variable.
valueThe value you want to add to ptr.
Returns
The new content of ptr.
template<typename T >
bool hamcast::util::atomic_cas ( volatile T **  ptr,
T *  ptr_expected,
T *  ptr_new 
)

Atomically compare the content of ptr to ptr_expected and, if they are the same, modify it to ptr_new.

Platform dependent, atomic compare-and-swap operation.

Parameters
ptrMemory location of the variable
ptr_expectedThe value you expect *ptr to be
ptr_newThe value which should be stored in *ptr
Returns
true if ptr was set to ptr_new; otherwise false