// Try to find a unique handle (integer) in a single pass. Since the map is ordered, we can search until
// we find a gap in the handle values.
handle_t candidate = 0;
- for (auto p : keyServiceMap) {
+ for (auto p : key_service_map) {
if (p.first == candidate) candidate++;
else break;
}
- bool is_unique = (serviceKeyMap.find(record) == serviceKeyMap.end());
+ bool is_unique = (service_key_map.find(record) == service_key_map.end());
// The following operations perform allocation (can throw std::bad_alloc). If an exception occurs we
// must undo any previous actions:
}
try {
- keyServiceMap[candidate] = record;
- serviceKeyMap.insert(std::make_pair(record, candidate));
+ key_service_map[candidate] = record;
+ service_key_map.insert(std::make_pair(record, candidate));
}
catch (...) {
if (is_unique) {
record->remove_listener(this);
}
- keyServiceMap.erase(candidate);
+ key_service_map.erase(candidate);
}
return candidate;
iob.deregister(loop);
// Clear service listeners
- for (auto p : serviceKeyMap) {
+ for (auto p : service_key_map) {
p.first->remove_listener(this);
}
// A mapping between service records and their associated numerical identifier used
// in communction
using handle_t = uint32_t;
- std::unordered_multimap<service_record *, handle_t> serviceKeyMap;
- std::map<handle_t, service_record *> keyServiceMap;
+ std::unordered_multimap<service_record *, handle_t> service_key_map;
+ std::map<handle_t, service_record *> key_service_map;
// Buffer for outgoing packets. Each outgoing back is represented as a vector<char>.
list<vector<char>> outbuf;
service_record *find_service_for_key(uint32_t key)
{
try {
- return keyServiceMap.at(key);
+ return key_service_map.at(key);
}
catch (std::out_of_range &exc) {
return nullptr;
void service_event(service_record * service, service_event_t event) noexcept final override
{
// For each service handle corresponding to the event, send an information packet.
- auto range = serviceKeyMap.equal_range(service);
+ auto range = service_key_map.equal_range(service);
auto & i = range.first;
auto & end = range.second;
try {