PMDK C++ bindings  1.13.0-git23.gf49772ac
This is the C++ bindings documentation for PMDK's libpmemobj.
Public Member Functions | List of all members
pmem::obj::experimental::mpsc_queue::worker Class Reference

mpsc_queue producer worker class. More...

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

Public Member Functions

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...
 

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()

Member Function Documentation

◆ 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");

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