David Blume's GitList
Repositories
testcode.git
Code
Commits
Branches
Tags
Search
Tree:
56e9725
Branches
Tags
c++11
main
start
testcode.git
product
scoped_set_adder.cpp
Add .clang-format
dblume
commited
56e9725
at 2023-08-12 23:24:26
scoped_set_adder.cpp
Blame
History
Raw
#include <iostream> #include <mutex> #include <set> #include "scoped_set_adder.hpp" namespace { std::mutex g_mutex; std::set<scoped_set_adder*> g_items; } // namespace scoped_set_adder::scoped_set_adder(std::string const& name) : name_(name) { std::lock_guard<std::mutex> lock(g_mutex); g_items.insert(this); } scoped_set_adder::~scoped_set_adder() { std::lock_guard<std::mutex> lock(g_mutex); g_items.erase(this); } bool scoped_set_adder::dump() { std::lock_guard<std::mutex> lock(g_mutex); bool ret = (g_items.size() > 0); std::cout << "Scoped sets exist: " << ret << ", count: " << g_items.size() << std::endl; return ret; }