61 std::vector<TrivialType> array(capacity);
89 std::vector<TrivialType> array(len);
120 std::vector<TrivialType> data = createIntArray(len, startValue);
130 INFO_STR(
"\n\ntest01a_Read1Write1\n");
134 fprintf(stderr,
"test01a_Read1Write1: %s\n", rb.
get_info().c_str());
138 std::thread getThread01(&TestRingbuffer11::getThreadType01,
this,
"test01a.get01", &rb, capacity);
139 std::thread putThread01(&TestRingbuffer11::putThreadType01,
this,
"test01a.put01", &rb, capacity, 0);
148 INFO_STR(
"\n\ntest01b_Read1Write1_Range\n");
152 fprintf(stderr,
"test01b_Read1Write1_Range: %s\n", rb.
get_info().c_str());
156 std::thread getThread01(&TestRingbuffer11::getRangeThreadType02,
this,
"test01b.getR01", &rb, capacity);
157 std::thread putThread01(&TestRingbuffer11::putRangeThreadType02,
this,
"test01b.putR01", &rb, capacity, 0);
166 INFO_STR(
"\n\ntest02a_Read4Write1\n");
171 fprintf(stderr,
"test02a_Read4Write1: %s\n", rb.
get_info().c_str());
175 std::thread getThread01(&TestRingbuffer11::getThreadType01,
this,
"test02a.get01", &rb, capacity/4);
176 std::thread getThread02(&TestRingbuffer11::getThreadType01,
this,
"test02a.get02", &rb, capacity/4);
177 std::thread putThread01(&TestRingbuffer11::putThreadType01,
this,
"test02a.put01", &rb, capacity, 0);
178 std::thread getThread03(&TestRingbuffer11::getThreadType01,
this,
"test02a.get03", &rb, capacity/4);
179 std::thread getThread04(&TestRingbuffer11::getThreadType01,
this,
"test02a.get04", &rb, capacity/4);
191 INFO_STR(
"\n\ntest02b_Read4Write1_Range\n");
196 fprintf(stderr,
"test02b_Read4Write1_Range: %s\n", rb.
get_info().c_str());
200 std::thread getThread01(&TestRingbuffer11::getRangeThreadType02,
this,
"test02b.getR01", &rb, capacity/4);
201 std::thread getThread02(&TestRingbuffer11::getRangeThreadType02,
this,
"test02b.getR02", &rb, capacity/4);
202 std::thread putThread01(&TestRingbuffer11::putRangeThreadType02,
this,
"test02b.putR01", &rb, capacity, 0);
203 std::thread getThread03(&TestRingbuffer11::getRangeThreadType02,
this,
"test02b.getR03", &rb, capacity/4);
204 std::thread getThread04(&TestRingbuffer11::getRangeThreadType02,
this,
"test02b.getR04", &rb, capacity/4);
216 INFO_STR(
"\n\ntest03a_Read8Write2\n");
221 fprintf(stderr,
"test03a_Read8Write2: %s\n", rb.
get_info().c_str());
225 std::thread getThread01(&TestRingbuffer11::getThreadType01,
this,
"test03a.get01", &rb, capacity/8);
226 std::thread getThread02(&TestRingbuffer11::getThreadType01,
this,
"test03a.get02", &rb, capacity/8);
227 std::thread putThread01(&TestRingbuffer11::putThreadType01,
this,
"test03a.put01", &rb, capacity/2, 0);
228 std::thread getThread03(&TestRingbuffer11::getThreadType01,
this,
"test03a.get03", &rb, capacity/8);
229 std::thread getThread04(&TestRingbuffer11::getThreadType01,
this,
"test03a.get04", &rb, capacity/8);
231 std::thread getThread05(&TestRingbuffer11::getThreadType01,
this,
"test03a.get05", &rb, capacity/8);
232 std::thread getThread06(&TestRingbuffer11::getThreadType01,
this,
"test03a.get06", &rb, capacity/8);
233 std::thread putThread02(&TestRingbuffer11::putThreadType01,
this,
"test03a.put02", &rb, capacity/2, 400);
234 std::thread getThread07(&TestRingbuffer11::getThreadType01,
this,
"test03a.get07", &rb, capacity/8);
235 std::thread getThread08(&TestRingbuffer11::getThreadType01,
this,
"test03a.get08", &rb, capacity/8);
253 INFO_STR(
"\n\ntest03b_Read8Write2_Range\n");
258 fprintf(stderr,
"test03b_Read8Write2_Range: %s\n", rb.
get_info().c_str());
262 std::thread getThread01(&TestRingbuffer11::getRangeThreadType02,
this,
"test03b.getR01", &rb, capacity/8);
263 std::thread getThread02(&TestRingbuffer11::getRangeThreadType02,
this,
"test03b.getR02", &rb, capacity/8);
264 std::thread putThread01(&TestRingbuffer11::putRangeThreadType02,
this,
"test03b.putR01", &rb, capacity/2, 0);
265 std::thread getThread03(&TestRingbuffer11::getRangeThreadType02,
this,
"test03b.getR03", &rb, capacity/8);
266 std::thread getThread04(&TestRingbuffer11::getRangeThreadType02,
this,
"test03b.getR04", &rb, capacity/8);
268 std::thread getThread05(&TestRingbuffer11::getRangeThreadType02,
this,
"test03b.getR05", &rb, capacity/8);
269 std::thread getThread06(&TestRingbuffer11::getRangeThreadType02,
this,
"test03b.getR06", &rb, capacity/8);
270 std::thread putThread02(&TestRingbuffer11::putRangeThreadType02,
this,
"test03b.putR02", &rb, capacity/2, 400);
271 std::thread getThread07(&TestRingbuffer11::getRangeThreadType02,
this,
"test03b.getR07", &rb, capacity/8);
272 std::thread getThread08(&TestRingbuffer11::getRangeThreadType02,
this,
"test03b.getR08", &rb, capacity/8);
#define REQUIRE_MSG(MSG,...)
void test01b_Read1Write1_Range()
void test02a_Read4Write1()
void test03b_Read8Write2_Range()
void test01a_Read1Write1()
void test02b_Read4Write1_Range()
void test03a_Read8Write2()
Ring buffer implementation, a.k.a circular buffer, exposing lock-free get*(..) and put*(....
bool putBlocking(Value_type &&e, const fraction_i64 &timeout, bool &timeout_occurred) noexcept
Enqueues the given element by moving it into this ringbuffer storage.
bool put(Value_type &&e) noexcept
Enqueues the given element by moving it into this ringbuffer storage.
Size_type size() const noexcept
Returns the number of elements in this ring buffer.
bool getBlocking(Value_type &result, const fraction_i64 &timeout, bool &timeout_occurred) noexcept
Dequeues the oldest enqueued element.
constexpr_non_literal_var void setMultiPCEnabled(const bool v)
Enable or disable capability to handle multiple producer and consumer, see ringbuffer_multi_pc and ri...
bool isFull() const noexcept
Returns true if this ring buffer is full, otherwise false.
bool isEmpty() const noexcept
Returns true if this ring buffer is empty, otherwise false.
std::string toString() const noexcept
Returns a short string representation incl.
std::string get_info() const noexcept
std::string to_string(const alphabet &v) noexcept
uint_fast32_t nsize_t
Natural 'size_t' alternative using uint_fast32_t as its natural sized type.
constexpr const jau::fraction_i64 zero(0l, 1lu)
zero is 0/1
__pack(...): Produces MSVC, clang and gcc compatible lead-in and -out macros.
static constexpr const IntegralType integral_modulus
constexpr const TrivialType TrivialTypeNullElem(0xff)
ringbuffer< TrivialType, jau::nsize_t > TrivialTypeRingbuffer
METHOD_AS_TEST_CASE(TestRingbuffer11::test_sequential, "Test TestRingbuffer 11- test_sequential")