Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Struct template spsc_value

boost::lockfree::spsc_value

Synopsis

// In header: <boost/lockfree/spsc_value.hpp>

template<typename T,  Options> 
struct spsc_value {

  // public member functions
  ();
  ();
   ();
   ();
   ();
   ();
  template<typename Functor>  ();
};

Description

The spcs_value provides a single-writer/single-reader value, implemented by a triple buffer

Policies:

spsc_value public member functions

  1. ();

    Construct a spsc_value

    If configured with boost::lockfree::allow_multiple_reads<true> it is initialized to a default-constructed value

  2. ( value);

    Construct a spsc_value, initialized to a value

  3.  ( value);

    Writes value to the spsc_value

    [Note] Note

    Thread-safe and wait-free

    Requires:

    only one thread is allowed to write data to the spsc_value

    Postconditions:

    object will be written to the spsc_value

  4.  ( value);

    Writes value to the spsc_value

    [Note] Note

    Thread-safe and wait-free

    Requires:

    only one thread is allowed to write data to the spsc_value

    Postconditions:

    object will be written to the spsc_value

  5.  ( ret);

    Reads content of the spsc_value

    [Note] Note

    Thread-safe and wait-free

    Requires:

    only one thread is allowed to write data to the spsc_value

    Postconditions:

    if read operation is successful, object will be copied to ret.

    Returns:

    true, if the read operation is successful, false if the spsc_value is configured with boost::lockfree::allow_multiple_reads<false> and no value is available for reading

  6.  ();

    Reads content of the spsc_value, returning an optional

    [Note] Note

    Thread-safe and wait-free

    Requires:

    only one thread is allowed to write data to the spsc_value

    Returns:

    std::optional with value if successful, std::nullopt if spsc_value is configured with boost::lockfree::allow_multiple_reads<false> and no value is available for reading

  7. template<typename Functor>  ( f);

    consumes value via a functor

    reads element from the spsc_value and applies the functor on this object

    [Note] Note

    Thread-safe and non-blocking, if functor is thread-safe and non-blocking

    Returns:

    true, if element was consumed


PrevUpHomeNext