[config][test] added .clang-format
This commit is contained in:
parent
07508ba343
commit
7b7e478a8d
1
.clang-format
Normal file
1
.clang-format
Normal file
@ -0,0 +1 @@
|
||||
BasedOnStyle: Chromium
|
||||
@ -4,6 +4,6 @@
|
||||
"conan": {}
|
||||
},
|
||||
"include": [
|
||||
"build/Release/generators/CMakePresets.json"
|
||||
"build/Debug/generators/CMakePresets.json"
|
||||
]
|
||||
}
|
||||
@ -1 +1 @@
|
||||
build/Release/compile_commands.json
|
||||
build/Debug/compile_commands.json
|
||||
22
main.cc
22
main.cc
@ -4,17 +4,20 @@
|
||||
|
||||
static constexpr size_t repeat = 1 << 20;
|
||||
|
||||
void producer(moodycamel::ReaderWriterQueue<int>& queue) {
|
||||
for(int i = 0; i < repeat; ++i) {
|
||||
while(!queue.try_enqueue(i)) { std::this_thread::yield(); }
|
||||
void producer(moodycamel::ReaderWriterQueue<std::string>& queue) {
|
||||
std::string str{"10"};
|
||||
for (int i = 0; i < repeat; ++i) {
|
||||
while (!queue.try_enqueue(str)) {
|
||||
std::this_thread::yield();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void consumer(moodycamel::ReaderWriterQueue<int>& queue) {
|
||||
void consumer(moodycamel::ReaderWriterQueue<std::string>& queue) {
|
||||
size_t counter = 0;
|
||||
int val = 0;
|
||||
while(counter < repeat) {
|
||||
while(!queue.try_dequeue(val)) {
|
||||
std::string val;
|
||||
while (counter < repeat) {
|
||||
while (!queue.try_dequeue(val)) {
|
||||
std::this_thread::yield();
|
||||
}
|
||||
++counter;
|
||||
@ -22,13 +25,12 @@ void consumer(moodycamel::ReaderWriterQueue<int>& queue) {
|
||||
}
|
||||
|
||||
TEST(BASIC, rwq) {
|
||||
moodycamel::ReaderWriterQueue<int> queue;
|
||||
moodycamel::ReaderWriterQueue<std::string> queue;
|
||||
std::jthread t1{&producer, std::ref(queue)};
|
||||
std::jthread t2{&consumer, std::ref(queue)};
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
int main(int argc, char** argv) {
|
||||
testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user