From: Casey Bodley Date: Fri, 17 Aug 2018 17:40:25 +0000 (-0400) Subject: rgw: add RGWAioCompletionNotifierWith X-Git-Tag: v14.0.1~376^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=de4376f0405c8c172651bbd27f370b63d03614a8;p=ceph.git rgw: add RGWAioCompletionNotifierWith Signed-off-by: Casey Bodley --- diff --git a/src/rgw/rgw_coroutine.h b/src/rgw/rgw_coroutine.h index 73841f2ebe945..8c1e25dc58a70 100644 --- a/src/rgw/rgw_coroutine.h +++ b/src/rgw/rgw_coroutine.h @@ -135,6 +135,18 @@ public: } }; +// completion notifier with opaque payload (ie a reference-counted pointer) +template +class RGWAioCompletionNotifierWith : public RGWAioCompletionNotifier { + T value; +public: + RGWAioCompletionNotifierWith(RGWCompletionManager *mgr, + const rgw_io_id& io_id, void *user_data, + T value) + : RGWAioCompletionNotifier(mgr, io_id, user_data), value(std::move(value)) + {} +}; + struct RGWCoroutinesEnv { uint64_t run_context; RGWCoroutinesManager *manager; @@ -479,6 +491,8 @@ public: void cancel(); RGWAioCompletionNotifier *create_completion_notifier(); + template + RGWAioCompletionNotifier *create_completion_notifier(T value); RGWCompletionManager *get_completion_mgr(); void set_blocked_by(RGWCoroutinesStack *s) { @@ -596,6 +610,8 @@ public: virtual void report_error(RGWCoroutinesStack *op); RGWAioCompletionNotifier *create_completion_notifier(RGWCoroutinesStack *stack); + template + RGWAioCompletionNotifier *create_completion_notifier(RGWCoroutinesStack *stack, T value); RGWCompletionManager *get_completion_mgr() { return completion_mgr; } void schedule(RGWCoroutinesEnv *env, RGWCoroutinesStack *stack); @@ -615,6 +631,21 @@ public: } }; +template +RGWAioCompletionNotifier *RGWCoroutinesManager::create_completion_notifier(RGWCoroutinesStack *stack, T value) +{ + rgw_io_id io_id{get_next_io_id(), -1}; + RGWAioCompletionNotifier *cn = new RGWAioCompletionNotifierWith(completion_mgr, io_id, (void *)stack, std::move(value)); + completion_mgr->register_completion_notifier(cn); + return cn; +} + +template +RGWAioCompletionNotifier *RGWCoroutinesStack::create_completion_notifier(T value) +{ + return ops_mgr->create_completion_notifier(this, std::move(value)); +} + class RGWSimpleCoroutine : public RGWCoroutine { bool called_cleanup;