This repository was archived by the owner on Mar 22, 2023. It is now read-only.
File tree Expand file tree Collapse file tree
include/libpmemobj++/experimental Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -106,7 +106,12 @@ class mpsc_queue {
106106
107107 template <typename Function>
108108 bool try_produce (size_t size, Function &&f);
109- bool try_produce (pmem::obj::string_view data);
109+
110+ template <typename Function = void (*)(pmem::obj::string_view)>
111+ bool try_produce (
112+ pmem::obj::string_view data,
113+ Function &&on_produce =
114+ [](pmem::obj::string_view target) {});
110115
111116 private:
112117 mpsc_queue *queue;
@@ -377,8 +382,10 @@ mpsc_queue::worker::try_produce(size_t size, Function &&f)
377382 return true ;
378383}
379384
380- inline bool
381- mpsc_queue::worker::try_produce (pmem::obj::string_view data)
385+ template <typename Function>
386+ bool
387+ mpsc_queue::worker::try_produce (pmem::obj::string_view data,
388+ Function &&on_produce)
382389{
383390 auto req_size =
384391 pmem::detail::align_up (data.size () + sizeof (first_block::size),
@@ -398,6 +405,9 @@ mpsc_queue::worker::try_produce(pmem::obj::string_view data)
398405 ANNOTATE_HAPPENS_BEFORE (queue->ring_buffer .get ());
399406#endif
400407
408+ on_produce (pmem::obj::string_view (
409+ queue->buf + offset + sizeof (first_block::size), data.size ()));
410+
401411 ringbuf_produce (queue->ring_buffer .get (), w);
402412
403413 return true ;
You can’t perform that action at this time.
0 commit comments