From: Sage Weil Date: Mon, 21 Jul 2014 03:47:22 +0000 (-0700) Subject: include/Context: add generic C_Lock X-Git-Tag: v0.86~213^2~62 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=9cb2c815353dd70fdf03c02b31ae36e262657115;p=ceph.git include/Context: add generic C_Lock Wrap a callback in a Mutex. Signed-off-by: Sage Weil --- diff --git a/src/include/Context.h b/src/include/Context.h index 38af84325aed..d9533c5b6106 100644 --- a/src/include/Context.h +++ b/src/include/Context.h @@ -148,6 +148,23 @@ public: }; +struct C_Lock : public Context { + Mutex *lock; + Context *fin; + C_Lock(Mutex *l, Context *c) : lock(l), fin(c) {} + ~C_Lock() { + delete fin; + } + void finish(int r) { + if (fin) { + lock->Lock(); + fin->complete(r); + fin = NULL; + lock->Unlock(); + } + } +}; + /* * C_Contexts - set of Contexts */