From b7802b3b06511f067719cb845dfd03a223f0e18f Mon Sep 17 00:00:00 2001 From: Determinant Date: Wed, 3 Apr 2019 14:55:26 -0400 Subject: improve non-blocking API --- include/salticidae/buffer.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'include/salticidae/buffer.h') diff --git a/include/salticidae/buffer.h b/include/salticidae/buffer.h index 2324d8b..c7b11dd 100644 --- a/include/salticidae/buffer.h +++ b/include/salticidae/buffer.h @@ -126,14 +126,14 @@ struct MPSCWriteBuffer { MPSCWriteBuffer(const SegBuffer &other) = delete; MPSCWriteBuffer(SegBuffer &&other) = delete; + void set_capacity(size_t capacity) { buffer.set_capacity(capacity); } + void rewind(bytearray_t &&data) { buffer.rewind(buffer_entry_t(std::move(data))); } - void push(bytearray_t &&data) { - buffer_entry_t d(std::move(data)); - // TODO: better bounded buffer impl - while (!buffer.try_enqueue(d)) {} + bool push(bytearray_t &&data, bool unbounded) { + return buffer.enqueue(buffer_entry_t(std::move(data)), unbounded); } bytearray_t move_pop() { -- cgit v1.2.3