void CurlMultiAwait::setFinished(int fd) { if (m_result < fd) { m_result = fd; } if (!m_finished) { markAsFinished(); m_finished = true; } }
void FileAwait::setFinished(int64_t status) { if (status > m_result) { m_result = status; } if (!m_finished) { markAsFinished(); m_finished = true; } }
void result(const mcr::mcrouter_msg_t* msg) { if (msg->reply.isError()) { setResultException(msg); } else { switch (msg->req->op) { case mc_op_add: case mc_op_set: case mc_op_replace: case mc_op_prepend: case mc_op_append: case mc_op_flushall: if (!msg->reply.isStored()) { setResultException(msg); break; } break; case mc_op_delete: if (msg->reply.result() != mc_res_deleted) { setResultException(msg); break; } break; case mc_op_incr: case mc_op_decr: if (!msg->reply.isStored()) { setResultException(msg); break; } m_result.m_type = KindOfInt64; m_result.m_data.num = msg->reply.delta(); break; case mc_op_get: if (msg->reply.isMiss()) { setResultException(msg); break; } /* fallthrough */ case mc_op_version: m_result.m_type = KindOfString; m_result.m_data.pstr = nullptr; // We're in the wrong thread for making a StringData // so stash it in a std::string until we get to unserialize m_stringResult = std::string((char*)msg->reply.value().data(), msg->reply.value().length()); break; default: always_assert(false); } } markAsFinished(); }
void IconFetchJob::handleSuccessfulReply(QNetworkReply *reply) { QPixmap pixmap; if (pixmap.loadFromData(reply->readAll())) { m_icon = QIcon(pixmap); } if (m_icon.isNull()) { markAsFailure(); } markAsFinished(); }
CurlMultiAwait::CurlMultiAwait(req::ptr<CurlMultiResource> multi, double timeout) { if ((addLowHandles(multi) + addHighHandles(multi)) == 0) { // Nothing to do markAsFinished(); return; } // Add optional timeout int64_t timeout_ms = timeout * 1000; if (timeout_ms > 0) { auto asio_event_base = getSingleton<AsioEventBase>(); m_timeout = req::make_shared<CurlTimeoutHandler>(asio_event_base.get(), this); asio_event_base->runInEventBaseThreadAndWait([this,timeout_ms] { m_timeout->scheduleTimeout(timeout_ms); }); } }
void c_AwaitAllWaitHandle::onUnblocked(uint32_t idx) { assert(idx <= m_unfinished); assert(getState() == STATE_BLOCKED); if (idx == m_unfinished) { for (uint32_t next = idx - 1; next < idx; --next) { auto const child = m_children[next].m_child; if (!child->isFinished()) { // Found the next unfinished child. m_unfinished = next; // Make sure there's no cyclic dependencies. try { detectCycle(child); } catch (const Object& cycle_exception) { markAsFailed(cycle_exception); } return; } } // All children finished. markAsFinished(); } }
void DataFetchJob::handleSuccessfulReply(QNetworkReply *reply) { m_reply = reply; markAsFinished(); }