void threaded_listener::process_item(queue_item_type &item) { try { if (!item.notify_guard) { notify_disconnected(item.to); } else if (item.for_open) { if (item.notify_guard->open()) { // open once try { notify_connection_opened(item.to, item.id); item.notify_guard->commit(); // allow notify close for next event } catch (...) { item.notify_guard->cancel(); // disallow notify close for next event data_.notify_connection_opened_failed(item.to, item.id); } } } else if (item.notify_guard->close()) { // close once (if not canceled) notify_connection_closed(item.to, item.id); } } catch (...) { } }
void threaded_listener::thread_func() { queue_item_type item; while (items_.pop(item)) { data_type const &dt = item.first; if (item.second) { notify_connection_opened(dt.first, dt.second); } else if (dt.second) { notify_connection_closed(dt.first, dt.second); } else { notify_disconnected(dt.first); } } }