#include <iostream>
#include <cassert>
#include <cinttypes>
#include <cstring>
#include <memory>
#include <thread>
#include <pthread.h>
#define CATCH_CONFIG_MAIN
#include <catch2/catch_amalgamated.hpp>
private:
return rb;
}
return rb;
}
std::vector<TrivialType> array(capacity);
}
return array;
}
}
(void)msg;
}
std::vector<TrivialType> array(len);
}
(void)msg;
}
}
(void)msg;
}
std::vector<TrivialType> data = createIntArray(len, startValue);
(void)msg;
}
public:
void test01a_Read1Write1() {
std::thread getThread01(&TestRingbuffer11::getThreadType01, this, "test01a.get01", &rb, capacity);
std::thread putThread01(&TestRingbuffer11::putThreadType01, this, "test01a.put01", &rb, capacity, 0);
putThread01.join();
getThread01.join();
}
void test01b_Read1Write1_Range() {
INFO_STR(
"\n\ntest01b_Read1Write1_Range\n");
std::thread getThread01(&TestRingbuffer11::getRangeThreadType02, this, "test01b.getR01", &rb, capacity);
std::thread putThread01(&TestRingbuffer11::putRangeThreadType02, this, "test01b.putR01", &rb, capacity, 0);
putThread01.join();
getThread01.join();
}
void test02a_Read4Write1() {
std::thread getThread01(&TestRingbuffer11::getThreadType01, this, "test02a.get01", &rb, capacity/4);
std::thread getThread02(&TestRingbuffer11::getThreadType01, this, "test02a.get02", &rb, capacity/4);
std::thread putThread01(&TestRingbuffer11::putThreadType01, this, "test02a.put01", &rb, capacity, 0);
std::thread getThread03(&TestRingbuffer11::getThreadType01, this, "test02a.get03", &rb, capacity/4);
std::thread getThread04(&TestRingbuffer11::getThreadType01, this, "test02a.get04", &rb, capacity/4);
putThread01.join();
getThread01.join();
getThread02.join();
getThread03.join();
getThread04.join();
}
void test02b_Read4Write1_Range() {
INFO_STR(
"\n\ntest02b_Read4Write1_Range\n");
std::thread getThread01(&TestRingbuffer11::getRangeThreadType02, this, "test02b.getR01", &rb, capacity/4);
std::thread getThread02(&TestRingbuffer11::getRangeThreadType02, this, "test02b.getR02", &rb, capacity/4);
std::thread putThread01(&TestRingbuffer11::putRangeThreadType02, this, "test02b.putR01", &rb, capacity, 0);
std::thread getThread03(&TestRingbuffer11::getRangeThreadType02, this, "test02b.getR03", &rb, capacity/4);
std::thread getThread04(&TestRingbuffer11::getRangeThreadType02, this, "test02b.getR04", &rb, capacity/4);
putThread01.join();
getThread01.join();
getThread02.join();
getThread03.join();
getThread04.join();
}
void test03a_Read8Write2() {
std::thread getThread01(&TestRingbuffer11::getThreadType01, this, "test03a.get01", &rb, capacity/8);
std::thread getThread02(&TestRingbuffer11::getThreadType01, this, "test03a.get02", &rb, capacity/8);
std::thread putThread01(&TestRingbuffer11::putThreadType01, this, "test03a.put01", &rb, capacity/2, 0);
std::thread getThread03(&TestRingbuffer11::getThreadType01, this, "test03a.get03", &rb, capacity/8);
std::thread getThread04(&TestRingbuffer11::getThreadType01, this, "test03a.get04", &rb, capacity/8);
std::thread getThread05(&TestRingbuffer11::getThreadType01, this, "test03a.get05", &rb, capacity/8);
std::thread getThread06(&TestRingbuffer11::getThreadType01, this, "test03a.get06", &rb, capacity/8);
std::thread putThread02(&TestRingbuffer11::putThreadType01, this, "test03a.put02", &rb, capacity/2, 400);
std::thread getThread07(&TestRingbuffer11::getThreadType01, this, "test03a.get07", &rb, capacity/8);
std::thread getThread08(&TestRingbuffer11::getThreadType01, this, "test03a.get08", &rb, capacity/8);
putThread01.join();
putThread02.join();
getThread01.join();
getThread02.join();
getThread03.join();
getThread04.join();
getThread05.join();
getThread06.join();
getThread07.join();
getThread08.join();
}
void test03b_Read8Write2_Range() {
INFO_STR(
"\n\ntest03b_Read8Write2_Range\n");
std::thread getThread01(&TestRingbuffer11::getRangeThreadType02, this, "test03b.getR01", &rb, capacity/8);
std::thread getThread02(&TestRingbuffer11::getRangeThreadType02, this, "test03b.getR02", &rb, capacity/8);
std::thread putThread01(&TestRingbuffer11::putRangeThreadType02, this, "test03b.putR01", &rb, capacity/2, 0);
std::thread getThread03(&TestRingbuffer11::getRangeThreadType02, this, "test03b.getR03", &rb, capacity/8);
std::thread getThread04(&TestRingbuffer11::getRangeThreadType02, this, "test03b.getR04", &rb, capacity/8);
std::thread getThread05(&TestRingbuffer11::getRangeThreadType02, this, "test03b.getR05", &rb, capacity/8);
std::thread getThread06(&TestRingbuffer11::getRangeThreadType02, this, "test03b.getR06", &rb, capacity/8);
std::thread putThread02(&TestRingbuffer11::putRangeThreadType02, this, "test03b.putR02", &rb, capacity/2, 400);
std::thread getThread07(&TestRingbuffer11::getRangeThreadType02, this, "test03b.getR07", &rb, capacity/8);
std::thread getThread08(&TestRingbuffer11::getRangeThreadType02, this, "test03b.getR08", &rb, capacity/8);
putThread01.join();
putThread02.join();
getThread01.join();
getThread02.join();
getThread03.join();
getThread04.join();
getThread05.join();
getThread06.join();
getThread07.join();
getThread08.join();
}
void test_sequential() {
test01a_Read1Write1();
test02a_Read4Write1();
test03a_Read8Write2();
test01a_Read1Write1();
test02a_Read4Write1();
test03a_Read8Write2();
test03a_Read8Write2();
test03a_Read8Write2();
test03a_Read8Write2();
}
void test_range() {
test01b_Read1Write1_Range();
test02b_Read4Write1_Range();
test03b_Read8Write2_Range();
test01b_Read1Write1_Range();
test02b_Read4Write1_Range();
test03b_Read8Write2_Range();
test01b_Read1Write1_Range();
test02b_Read4Write1_Range();
test03b_Read8Write2_Range();
}
};