PMDK C++ bindings  1.13.0-git107.g7e59f08f
This is the C++ bindings documentation for PMDK's libpmemobj.
pmem::obj::experimental::mpsc_queue::worker Class Reference

mpsc_queue producer worker class. More...

#include <libpmemobj++/experimental/mpsc_queue.hpp>

Public Member Functions

 worker (mpsc_queue *q)
 Default constructor of worker object. More...
 
 ~worker ()
 Default destructor of worker object. More...
 
 worker (const worker &)=delete
 
workeroperator= (const worker &)=delete
 
 worker (worker &&other)
 Move constructor, from. More...
 
workeroperator= (worker &&other)
 Move assignment operator, from. More...
 
template<typename Function = void (*)(pmem::obj::string_view)>
bool try_produce (pmem::obj::string_view data, Function &&on_produce=[](pmem::obj::string_view target) {})
 Copies data from pmem::obj::string_view into the mpsc_queue. More...
 

Friends

class mpsc_queue
 

Detailed Description

mpsc_queue producer worker class.

To write data concurrently into the mpsc_queue in the multi-threaded application, each producer thread have to use its own worker object. Workers might be added concurrently to the mpsc_queue.

Note
All workers have to be destroyed before destruction of the mpsc_queue
See also
mpsc_queue:try_produce_batch()

Constructor & Destructor Documentation

◆ worker() [1/2]

pmem::obj::experimental::mpsc_queue::worker::worker ( mpsc_queue q)
inline

Default constructor of worker object.

It's registered as a worker for passed mpsc_queue

Parameters
q.

◆ ~worker()

pmem::obj::experimental::mpsc_queue::worker::~worker ( )
inline

Default destructor of worker object.

It unregisters the worker (in ringbuf and in queue's manager).

◆ worker() [2/2]

pmem::obj::experimental::mpsc_queue::worker::worker ( mpsc_queue::worker &&  other)
inline

Move constructor, from.

Parameters
otherworker.

Member Function Documentation

◆ operator=()

mpsc_queue::worker & pmem::obj::experimental::mpsc_queue::worker::operator= ( worker &&  other)
inline

Move assignment operator, from.

Parameters
otherworker.

◆ try_produce()

template<typename Function = void (*)(pmem::obj::string_view)>
bool pmem::obj::experimental::mpsc_queue::worker::try_produce ( pmem::obj::string_view  data,
Function &&  on_produce = [](pmem::obj::string_view target) {} 
)

Copies data from pmem::obj::string_view into the mpsc_queue.

Parameters
[in]dataData to be copied into mpsc_queue
[in]on_produceFunction evaluated on the data in queue, before the data is visible for the consumer. By default do nothing.
Returns
true if f were evaluated, all data copied by it saved in the mpsc_queue, and are visible for the consumer.
/* Produce data to be consumed in next run of the application. */
worker.try_produce("Left for next run");
worker(mpsc_queue *q)
Default constructor of worker object.
Definition: mpsc_queue.hpp:474

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