0f3c85e7ce189f48716287b1cc8637100f09b5c9
David Blume Added scoped_set_adder.

David Blume authored 8 years ago

1) #include <iostream>
2) #include <mutex>
3) #include <set>
4) 
5) #include "scoped_set_adder.hpp"
6)  
7) namespace {
8)     std::mutex g_mutex;
9)     std::set<scoped_set_adder *> g_items;
10) }
11)  
12) scoped_set_adder::scoped_set_adder(std::string const& name) : name_(name) {
13)     std::lock_guard<std::mutex> lock(g_mutex);
14)     g_items.insert(this);
15) }
16)  
17) scoped_set_adder::~scoped_set_adder() {
18)     std::lock_guard<std::mutex> lock(g_mutex);
19)     g_items.erase(this);
20) }
21)  
David Blume Tweak scoped_set_adder

David Blume authored 7 years ago

22) bool scoped_set_adder::dump() {
David Blume Added scoped_set_adder.

David Blume authored 8 years ago

23)     std::lock_guard<std::mutex> lock(g_mutex);
24)     bool ret = (g_items.size() > 0);
David Blume Tweak scoped_set_adder

David Blume authored 7 years ago

25)     std::cout << "Scoped sets exist: " << ret << ", count: " << g_items.size() << std::endl;