David Blume's GitList
Repositories
testcode.git
Code
Commits
Branches
Tags
Search
Tree:
0f3c85e
Branches
Tags
c++11
main
start
testcode.git
product
scoped_set_adder.cpp
Tweak scoped_set_adder
David Blume
commited
0f3c85e
at 2017-06-18 14:45:21
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; } 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; }