80 std::vector<TrivialType> array(capacity);
108 std::vector<TrivialType> array(len);
139 std::vector<TrivialType> data = createIntArray(len, startValue);
149 INFO_STR(
"\n\ntest01a_Read1Write1\n");
153 fprintf(stderr,
"test01a_Read1Write1: %s\n", rb.
get_info().c_str());
157 std::thread getThread01(&TestRingbuffer12::getThreadType01,
this,
"test01a.get01", &rb, capacity);
158 std::thread putThread01(&TestRingbuffer12::putThreadType01,
this,
"test01a.put01", &rb, capacity, 0);
167 INFO_STR(
"\n\ntest01b_Read1Write1_Range\n");
171 fprintf(stderr,
"test01b_Read1Write1_Range: %s\n", rb.
get_info().c_str());
175 std::thread getThread01(&TestRingbuffer12::getRangeThreadType02,
this,
"test01b.getR01", &rb, capacity);
176 std::thread putThread01(&TestRingbuffer12::putRangeThreadType02,
this,
"test01b.putR01", &rb, capacity, 0);
185 INFO_STR(
"\n\ntest02a_Read4Write1\n");
190 fprintf(stderr,
"test02a_Read4Write1: %s\n", rb.
get_info().c_str());
194 std::thread getThread01(&TestRingbuffer12::getThreadType01,
this,
"test02a.get01", &rb, capacity/4);
195 std::thread getThread02(&TestRingbuffer12::getThreadType01,
this,
"test02a.get02", &rb, capacity/4);
196 std::thread putThread01(&TestRingbuffer12::putThreadType01,
this,
"test02a.put01", &rb, capacity, 0);
197 std::thread getThread03(&TestRingbuffer12::getThreadType01,
this,
"test02a.get03", &rb, capacity/4);
198 std::thread getThread04(&TestRingbuffer12::getThreadType01,
this,
"test02a.get04", &rb, capacity/4);
210 INFO_STR(
"\n\ntest02b_Read4Write1_Range\n");
215 fprintf(stderr,
"test02b_Read4Write1_Range: %s\n", rb.
get_info().c_str());
219 std::thread getThread01(&TestRingbuffer12::getRangeThreadType02,
this,
"test02b.getR01", &rb, capacity/4);
220 std::thread getThread02(&TestRingbuffer12::getRangeThreadType02,
this,
"test02b.getR02", &rb, capacity/4);
221 std::thread putThread01(&TestRingbuffer12::putRangeThreadType02,
this,
"test02b.putR01", &rb, capacity, 0);
222 std::thread getThread03(&TestRingbuffer12::getRangeThreadType02,
this,
"test02b.getR03", &rb, capacity/4);
223 std::thread getThread04(&TestRingbuffer12::getRangeThreadType02,
this,
"test02b.getR04", &rb, capacity/4);
235 INFO_STR(
"\n\ntest03a_Read8Write2\n");
240 fprintf(stderr,
"test03a_Read8Write2: %s\n", rb.
get_info().c_str());
244 std::thread getThread01(&TestRingbuffer12::getThreadType01,
this,
"test03a.get01", &rb, capacity/8);
245 std::thread getThread02(&TestRingbuffer12::getThreadType01,
this,
"test03a.get02", &rb, capacity/8);
246 std::thread putThread01(&TestRingbuffer12::putThreadType01,
this,
"test03a.put01", &rb, capacity/2, 0);
247 std::thread getThread03(&TestRingbuffer12::getThreadType01,
this,
"test03a.get03", &rb, capacity/8);
248 std::thread getThread04(&TestRingbuffer12::getThreadType01,
this,
"test03a.get04", &rb, capacity/8);
250 std::thread getThread05(&TestRingbuffer12::getThreadType01,
this,
"test03a.get05", &rb, capacity/8);
251 std::thread getThread06(&TestRingbuffer12::getThreadType01,
this,
"test03a.get06", &rb, capacity/8);
252 std::thread putThread02(&TestRingbuffer12::putThreadType01,
this,
"test03a.put02", &rb, capacity/2, 400);
253 std::thread getThread07(&TestRingbuffer12::getThreadType01,
this,
"test03a.get07", &rb, capacity/8);
254 std::thread getThread08(&TestRingbuffer12::getThreadType01,
this,
"test03a.get08", &rb, capacity/8);
272 INFO_STR(
"\n\ntest03b_Read8Write2_Range\n");
277 fprintf(stderr,
"test03b_Read8Write2_Range: %s\n", rb.
get_info().c_str());
281 std::thread getThread01(&TestRingbuffer12::getRangeThreadType02,
this,
"test03b.getR01", &rb, capacity/8);
282 std::thread getThread02(&TestRingbuffer12::getRangeThreadType02,
this,
"test03b.getR02", &rb, capacity/8);
283 std::thread putThread01(&TestRingbuffer12::putRangeThreadType02,
this,
"test03b.putR01", &rb, capacity/2, 0);
284 std::thread getThread03(&TestRingbuffer12::getRangeThreadType02,
this,
"test03b.getR03", &rb, capacity/8);
285 std::thread getThread04(&TestRingbuffer12::getRangeThreadType02,
this,
"test03b.getR04", &rb, capacity/8);
287 std::thread getThread05(&TestRingbuffer12::getRangeThreadType02,
this,
"test03b.getR05", &rb, capacity/8);
288 std::thread getThread06(&TestRingbuffer12::getRangeThreadType02,
this,
"test03b.getR06", &rb, capacity/8);
289 std::thread putThread02(&TestRingbuffer12::putRangeThreadType02,
this,
"test03b.putR02", &rb, capacity/2, 400);
290 std::thread getThread07(&TestRingbuffer12::getRangeThreadType02,
this,
"test03b.getR07", &rb, capacity/8);
291 std::thread getThread08(&TestRingbuffer12::getRangeThreadType02,
this,
"test03b.getR08", &rb, capacity/8);
#define REQUIRE_MSG(MSG,...)
Integer(const Integer &o) noexcept=default
static Integer valueOf(const IntegralType i)
Integer(Integer &&o) noexcept=default
Integer & operator=(Integer &&o) noexcept=default
IntegralType intValue() const
Integer & operator=(const Integer &o) noexcept=default
void test01b_Read1Write1_Range()
void test02b_Read4Write1_Range()
void test02a_Read4Write1()
void test03a_Read8Write2()
void test03b_Read8Write2_Range()
void test01a_Read1Write1()
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.
int_fast32_t snsize_t
Natural 'ssize_t' alternative using int_fast32_t as its natural sized type.
__pack(...): Produces MSVC, clang and gcc compatible lead-in and -out macros.
jau::snsize_t IntegralType
static const TrivialType TrivialTypeNullElem(-1)
METHOD_AS_TEST_CASE(TestRingbuffer12::test_sequential, "Test TestRingbuffer 12- test_sequential")
ringbuffer< TrivialType, jau::nsize_t > TrivialTypeRingbuffer