void ConnectionImpl::setup(Milliseconds timeout, SetupCallback cb) { _setupCallback = std::move(cb); _timer.setTimeout( timeout, [this] { _setupCallback(this, Status(ErrorCodes::ExceededTimeLimit, "timeout")); }); _setupQueue.push_back(this); if (_pushSetupQueue.size()) { _setupQueue.front()->_setupCallback(_setupQueue.front(), _pushSetupQueue.front()()); _setupQueue.pop_front(); _pushSetupQueue.pop_front(); } }
void ConnectionImpl::setup(Milliseconds timeout, SetupCallback cb) { _setupCallback = std::move(cb); _timer.setTimeout(timeout, [this] { _setupCallback(this, Status(ErrorCodes::NetworkInterfaceExceededTimeLimit, "timeout")); }); _setupQueue.push_back(this); if (_pushSetupQueue.size()) { auto connPtr = _setupQueue.front(); auto callback = _pushSetupQueue.front(); _setupQueue.pop_front(); _pushSetupQueue.pop_front(); auto refreshCb = connPtr->_setupCallback; connPtr->indicateUsed(); refreshCb(connPtr, callback()); } }