32 using namespace rsc::logging;
37 MembershipManager::MembershipManager() :
38 logger(Logger::getLogger(
"rsb.spread.MembershipManager")) {
39 RSCTRACE(
logger,
"MembershipManager() entered");
47 RSCDEBUG(
logger,
"Trying to join group with id " << group <<
" on SpreadConnection " << c);
48 boost::recursive_mutex::scoped_lock lock(
groupsMutex);
49 GroupMap::iterator i =
groups->find(group);
51 int refs = i->second.second;
52 RSCDEBUG(
logger,
"Group object already existing, ref count: " << refs);
55 i->second.first->join(c);
56 RSCINFO(
logger,
"Re-joined SpreadGroup with id " << group);
58 i->second.second = ++refs;
59 RSCTRACE(
logger,
"New group ref count: " << i->second.second);
61 RSCDEBUG(
logger,
"Group object not found, creating new one");
64 RSCINFO(
logger,
"Joined SpreadGroup with id " << group);
65 (*groups)[group] = make_pair(sg, 1);
70 RSCDEBUG(
logger,
"Checking if we want to leave group with id " << group <<
" on SpreadConnection " << c);
71 boost::recursive_mutex::scoped_lock lock(
groupsMutex);
72 GroupMap::iterator i =
groups->find(group);
74 int refs = i->second.second;
75 RSCDEBUG(
logger,
"Group object found, ref count: " << refs);
77 i->second.second = --refs;
78 RSCTRACE(
logger,
"New group ref count: " << i->second.second);
80 RSCTRACE(
logger,
"Count is 0, leaving group");
81 i->second.first->leave(c);
82 RSCINFO(
logger,
"Left SpreadGroup with id " << group);
85 RSCWARN(
logger,
"SpreadGroup with id " << group <<
" not found in GroupMap");