From: Melanie Subbiah Date: Thu, 4 Aug 2016 23:09:23 +0000 (-0700) Subject: Create trace points for thread events X-Git-Tag: v2016.08.08.00~8 X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=14410cc6cb0587cee511e15c61de9ce94819deae;p=folly.git Create trace points for thread events Summary: RequestContext update. Reviewed By: mibpl Differential Revision: D3604937 fbshipit-source-id: 07b315fe22a6dba40f0bab53c8092f35c172ae85 --- diff --git a/folly/io/async/Request.cpp b/folly/io/async/Request.cpp index 8ea7f3e3..dc46d9d8 100644 --- a/folly/io/async/Request.cpp +++ b/folly/io/async/Request.cpp @@ -105,16 +105,16 @@ void RequestContext::clearContextData(const std::string& val) { std::shared_ptr RequestContext::setContext( std::shared_ptr ctx) { - auto& prev = getStaticContext(); - if (ctx != prev) { + auto& curCtx = getStaticContext(); + if (ctx != curCtx) { using std::swap; - if (prev) { - prev->onUnset(); + if (curCtx) { + curCtx->onUnset(); } - if (ctx) { - ctx->onSet(); + swap(ctx, curCtx); + if (curCtx) { + curCtx->onSet(); } - swap(ctx, prev); } return ctx; }