From ef0952fadae6794e225c0c1654887408bcadbf64 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Sat, 6 Jun 2026 18:04:17 +0200 Subject: foo.cpp -> test/threads.cpp --- foo.cpp | 39 --------------------------------------- 1 file changed, 39 deletions(-) delete mode 100644 foo.cpp (limited to 'foo.cpp') diff --git a/foo.cpp b/foo.cpp deleted file mode 100644 index a7891bb..0000000 --- a/foo.cpp +++ /dev/null @@ -1,39 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include - -namespace { - -struct Counter { - std::mutex mtx; - std::size_t impl = 0; -}; - -void do_something(Counter& counter) { - std::lock_guard lck{counter.mtx}; - ++counter.impl; - std::cout << "Doing something #" << counter.impl << '\n'; -} - -} - -int main() { - try { - Counter counter; - std::array workers; - for (auto& worker : workers) { - worker = std::thread{&do_something, std::ref(counter)}; - } - for (auto& worker : workers) { - worker.join(); - } - } catch (const std::exception& e) { - std::cerr << e.what() << '\n'; - return 1; - } - return 0; -} -- cgit v1.3