From: John Spray Date: Thu, 30 Jun 2016 12:13:34 +0000 (+0100) Subject: mon: add with_monmap to MonClient X-Git-Tag: v11.0.1~60^2~71 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=85ba9a36673a9049b8cc8fb9418d4ae6fad1fc67;p=ceph.git mon: add with_monmap to MonClient Analogous to Objecter::with_osdmap, for safe access to the map. Signed-off-by: John Spray --- diff --git a/src/mon/MonClient.h b/src/mon/MonClient.h index dd88fb0fcc24..cc1f9bd4df5d 100644 --- a/src/mon/MonClient.h +++ b/src/mon/MonClient.h @@ -431,6 +431,22 @@ public: */ void get_version(string map, version_t *newest, version_t *oldest, Context *onfinish); + /** + * Run a callback within our lock, with a reference + * to the MonMap + */ + template + auto with_monmap(Callback&& cb, Args&&...args) -> + typename std::enable_if< + std::is_void< + decltype(cb(const_cast(monmap), + std::forward(args)...))>::value, + void>::type { + Mutex::Locker l(monc_lock); + std::forward(cb)(const_cast(monmap), + std::forward(args)...); + } + private: struct version_req_d { Context *context;