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

Grants read access to the first consumer that calls open on the resource. 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

 consumer_resource (buffer_ptr buf)
 
 consumer_resource (consumer_resource &&)=default
 
 consumer_resource (const consumer_resource &)=default
 
consumer_resourceoperator= (consumer_resource &&)=default
 
consumer_resourceoperator= (const consumer_resource &)=default
 
consumer_resourceoperator= (std::nullptr_t)
 
buffer_ptr try_open ()
 Tries to open the resource for reading from the buffer.
 
template<class Coordinator >
auto observe_on (Coordinator *ctx) const
 Convenience function for calling ctx->make_observable().from_resource(*this).
 
void cancel ()
 Calls try_open and on success immediately calls cancel on the buffer.
 
bool valid () const noexcept
 
 operator bool () const noexcept
 
bool operator! () const noexcept
 

Friends

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

Detailed Description

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

Grants read access to the first consumer that calls open on the resource.

Cancels consumption of items on the buffer if the resources gets destroyed before opening it.

Member Function Documentation

◆ try_open()

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

Tries to open the resource for reading from 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: