C++ Actor Framework 1.0.0
Loading...
Searching...
No Matches
caf::async::producer_resource< T > Class Template Reference

Grants access to a buffer to the first producer that calls open. More...

#include <spsc_buffer.hpp>

Public Types

using value_type = T
 
using buffer_type = spsc_buffer<T>
 
using buffer_ptr = spsc_buffer_ptr<T>
 

Public Member Functions

 producer_resource (buffer_ptr buf)
 
 producer_resource (producer_resource &&)=default
 
 producer_resource (const producer_resource &)=default
 
producer_resourceoperator= (producer_resource &&)=default
 
producer_resourceoperator= (const producer_resource &)=default
 
producer_resourceoperator= (std::nullptr_t)
 
buffer_ptr try_open ()
 Tries to open the resource for writing to the buffer.
 
void close ()
 Calls try_open and on success immediately calls close on the buffer.
 
void abort (error reason)
 Calls try_open and on success immediately calls abort on the buffer.
 
bool valid () const noexcept
 
 operator bool () const noexcept
 
bool operator! () const noexcept
 

Friends

bool operator== (const producer_resource &lhs, const producer_resource &rhs)
 
bool operator!= (const producer_resource &lhs, const producer_resource &rhs)
 

Detailed Description

template<class T>
class caf::async::producer_resource< T >

Grants access to a buffer to the first producer that calls open.

Aborts writes on the buffer if the resources gets destroyed before opening it.

Member Function Documentation

◆ try_open()

template<class T >
buffer_ptr caf::async::producer_resource< T >::try_open ( )

Tries to open the resource for writing to the buffer.

The first open wins on concurrent access.

Returns
a pointer to the buffer on success, nullptr otherwise.

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