[config][test] added .clang-format

This commit is contained in:
Artur Mukhamadiev 2025-06-04 18:05:34 +00:00
parent 07508ba343
commit 7b7e478a8d
4 changed files with 23 additions and 20 deletions

1
.clang-format Normal file
View File

@ -0,0 +1 @@
BasedOnStyle: Chromium

View File

@ -4,6 +4,6 @@
"conan": {}
},
"include": [
"build/Release/generators/CMakePresets.json"
"build/Debug/generators/CMakePresets.json"
]
}

View File

@ -1 +1 @@
build/Release/compile_commands.json
build/Debug/compile_commands.json

22
main.cc
View File

@ -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();
}