From: Casey Bodley Date: Thu, 15 Feb 2024 03:50:40 +0000 (-0500) Subject: rgw/dmclock: async_request() uses async_initiate X-Git-Tag: v20.0.0~1890^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d478d66bf38f1e9edf10fd364bbdec0b39923626;p=ceph.git rgw/dmclock: async_request() uses async_initiate Signed-off-by: Casey Bodley --- diff --git a/src/rgw/rgw_dmclock_async_scheduler.h b/src/rgw/rgw_dmclock_async_scheduler.h index f18318f30298..01ca0a3a8033 100644 --- a/src/rgw/rgw_dmclock_async_scheduler.h +++ b/src/rgw/rgw_dmclock_async_scheduler.h @@ -125,38 +125,35 @@ auto AsyncScheduler::async_request(const client_id& client, const Time& time, Cost cost, CompletionToken&& token) { - boost::asio::async_completion init(token); - - auto ex1 = get_executor(); - auto& handler = init.completion_handler; - - // allocate the Request and add it to the queue - auto completion = Completion::create(ex1, std::move(handler), - Request{client, time, cost}); - // cast to unique_ptr - auto req = RequestRef{std::move(completion)}; - int r = queue.add_request(std::move(req), client, params, time, cost); - if (r == 0) { - // schedule an immediate call to process() on the executor - schedule(crimson::dmclock::TimeZero); - if (auto c = counters(client)) { - c->inc(queue_counters::l_qlen); - c->inc(queue_counters::l_cost, cost); - } - } else { - // post the error code - boost::system::error_code ec(r, boost::system::system_category()); - // cast back to Completion - auto completion = static_cast(req.release()); - async::post(std::unique_ptr{completion}, - ec, PhaseType::priority); - if (auto c = counters(client)) { - c->inc(queue_counters::l_limit); - c->inc(queue_counters::l_limit_cost, cost); - } - } - - return init.result.get(); + return boost::asio::async_initiate( + [this] (auto handler, auto ex, const client_id& client, + const ReqParams& params, const Time& time, Cost cost) { + // allocate the Request and add it to the queue + auto completion = Completion::create(ex, std::move(handler), + Request{client, time, cost}); + // cast to unique_ptr + auto req = RequestRef{std::move(completion)}; + int r = queue.add_request(std::move(req), client, params, time, cost); + if (r == 0) { + // schedule an immediate call to process() on the executor + schedule(crimson::dmclock::TimeZero); + if (auto c = counters(client)) { + c->inc(queue_counters::l_qlen); + c->inc(queue_counters::l_cost, cost); + } + } else { + // post the error code + boost::system::error_code ec(r, boost::system::system_category()); + // cast back to Completion + auto completion = static_cast(req.release()); + async::post(std::unique_ptr{completion}, + ec, PhaseType::priority); + if (auto c = counters(client)) { + c->inc(queue_counters::l_limit); + c->inc(queue_counters::l_limit_cost, cost); + } + } + }, token, get_executor(), client, params, time, cost); } class SimpleThrottler : public md_config_obs_t, public dmclock::Scheduler {