Commit 8174190b authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook GitHub Bot

Use RequestToken in RequestEventBase

Summary: [Folly] Use `RequestToken` in `RequestEventBase` to speed up lookup.

Reviewed By: zhxchen17

Differential Revision: D21529465

fbshipit-source-id: eaaef7b48be2c5a8d76fb5f4a5293f7db7e68bed
parent ed5983fe
......@@ -84,7 +84,7 @@ class RequestEventBase : public RequestData {
public:
static EventBase* get() {
auto data = dynamic_cast<RequestEventBase*>(
RequestContext::get()->getContextData(kContextDataName));
RequestContext::get()->getContextData(token()));
if (!data) {
return nullptr;
}
......@@ -93,8 +93,7 @@ class RequestEventBase : public RequestData {
static void set(EventBase* eb) {
RequestContext::get()->setContextData(
kContextDataName,
std::unique_ptr<RequestEventBase>(new RequestEventBase(eb)));
token(), std::unique_ptr<RequestEventBase>(new RequestEventBase(eb)));
}
bool hasCallback() override {
......@@ -102,6 +101,11 @@ class RequestEventBase : public RequestData {
}
private:
FOLLY_EXPORT static RequestToken const& token() {
static RequestToken const token(kContextDataName);
return token;
}
explicit RequestEventBase(EventBase* eb) : eb_(eb) {}
EventBase* eb_;
static constexpr const char* kContextDataName{"EventBase"};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment