[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": {}
|
"conan": {}
|
||||||
},
|
},
|
||||||
"include": [
|
"include": [
|
||||||
"build/Release/generators/CMakePresets.json"
|
"build/Debug/generators/CMakePresets.json"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@ -1 +1 @@
|
|||||||
build/Release/compile_commands.json
|
build/Debug/compile_commands.json
|
||||||
16
main.cc
16
main.cc
@ -4,15 +4,18 @@
|
|||||||
|
|
||||||
static constexpr size_t repeat = 1 << 20;
|
static constexpr size_t repeat = 1 << 20;
|
||||||
|
|
||||||
void producer(moodycamel::ReaderWriterQueue<int>& queue) {
|
void producer(moodycamel::ReaderWriterQueue<std::string>& queue) {
|
||||||
|
std::string str{"10"};
|
||||||
for (int i = 0; i < repeat; ++i) {
|
for (int i = 0; i < repeat; ++i) {
|
||||||
while(!queue.try_enqueue(i)) { std::this_thread::yield(); }
|
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;
|
size_t counter = 0;
|
||||||
int val = 0;
|
std::string val;
|
||||||
while (counter < repeat) {
|
while (counter < repeat) {
|
||||||
while (!queue.try_dequeue(val)) {
|
while (!queue.try_dequeue(val)) {
|
||||||
std::this_thread::yield();
|
std::this_thread::yield();
|
||||||
@ -22,13 +25,12 @@ void consumer(moodycamel::ReaderWriterQueue<int>& queue) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(BASIC, rwq) {
|
TEST(BASIC, rwq) {
|
||||||
moodycamel::ReaderWriterQueue<int> queue;
|
moodycamel::ReaderWriterQueue<std::string> queue;
|
||||||
std::jthread t1{&producer, std::ref(queue)};
|
std::jthread t1{&producer, std::ref(queue)};
|
||||||
std::jthread t2{&consumer, 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);
|
testing::InitGoogleTest(&argc, argv);
|
||||||
return RUN_ALL_TESTS();
|
return RUN_ALL_TESTS();
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user