add some more methods... :-D
parent
e03a99763a
commit
86f591ea01
|
@ -36,3 +36,16 @@ void SessionRegistry::remove(std::thread::id tid)
|
|||
m.erase(q);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
std::string SessionRegistry::to_string() const
|
||||
{
|
||||
Lock L(_mtx);
|
||||
std::stringstream ss;
|
||||
ss << m.size() << " session" << (m.size()==1?"":"s") << " in registry" << (m.empty()?".\n":":\n");
|
||||
for(const auto& e:m)
|
||||
{
|
||||
ss << "\t" << e.first << ": " << e.second << "\n";
|
||||
}
|
||||
return ss.str();
|
||||
}
|
||||
|
|
|
@ -18,6 +18,11 @@ public:
|
|||
PEP_SESSION get(std::thread::id tid = std::this_thread::get_id());
|
||||
void remove(std::thread::id tid = std::this_thread::get_id());
|
||||
|
||||
std::size_t size() const { return m.size(); }
|
||||
bool empty() const { return m.empty(); }
|
||||
|
||||
std::string to_string() const;
|
||||
|
||||
private:
|
||||
std::map<std::thread::id, PEP_SESSION> m;
|
||||
messageToSend_t mts;
|
||||
|
@ -25,7 +30,7 @@ private:
|
|||
|
||||
typedef std::recursive_mutex Mutex;
|
||||
typedef std::unique_lock<Mutex> Lock;
|
||||
Mutex _mtx;
|
||||
mutable Mutex _mtx;
|
||||
};
|
||||
|
||||
#endif // JSON_ADAPTER_SESSION_REGISTRY_HH
|
||||
|
|
Loading…
Reference in New Issue