API to set folly::RequestContext for current scope
authorMirek Klimos <miro@fb.com>
Mon, 18 Apr 2016 21:28:06 +0000 (14:28 -0700)
committerFacebook Github Bot 6 <facebook-github-bot-6-bot@fb.com>
Mon, 18 Apr 2016 21:35:24 +0000 (14:35 -0700)
commit35a8cc207284214b981d289469b83c83780c9f54
tree8f0e5105b08bdb4943bcb681810856d3f43e534e
parent9ef64521a65b60d4fea8e1b56ea0b283680921e5
API to set folly::RequestContext for current scope

Summary:There're currently two ways to set RequestContext
- RequestContext::create() - creates new context and sets it
- RequestContext::setContext(context) - sets context previously captured by saveContext
In most cases, the RequestContext is set back after the request is processed but sometimes it's not (especially with RequestContext::create). We want to measure cpu time for a request by measuring the total cpu time when a RequestContext is set, so we need to make sure that it's properly reset after the thread is done with the request. Scope guards can help us with that.

Reviewed By: haijunz

Differential Revision: D3156698

fb-gh-sync-id: cfb678531810e8be5faaf02cb7803bd247557e42
fbshipit-source-id: cfb678531810e8be5faaf02cb7803bd247557e42
folly/io/async/Request.h