Commit 5b373171 authored by Srivatsan Ramesh's avatar Srivatsan Ramesh Committed by Facebook GitHub Bot

Using reply struct instead of folly::Function

Summary: Using folly::Function as node type for EventBaseAtomicNotificationQueue involves two mallocs (for creating the function and also to create the queue node). In this diff, I have created a class to hold the data required to send replies and using emplaceMessage to add to the queue.

Differential Revision: D26778920

fbshipit-source-id: 2dcf8395dc77db1d7c73d1d68c9a69e767191b95
parent 7cdcfcab
......@@ -151,6 +151,11 @@ class ExecutionObserverScopeGuard {
namespace folly {
class EventBase::FuncRunner {
public:
void operator()(Func func) noexcept { func(); }
};
/*
* EventBase methods
*/
......
......@@ -143,16 +143,6 @@ class EventBase : public TimeoutManager,
using Func = folly::Function<void()>;
class FuncRunner {
public:
void operator()(Func&& func) noexcept {
func();
func = nullptr;
}
};
using EventBaseQueue = EventBaseAtomicNotificationQueue<Func, FuncRunner>;
/**
* A callback interface to use with runInLoop()
*
......@@ -865,6 +855,8 @@ class EventBase : public TimeoutManager,
}
private:
class FuncRunner;
folly::VirtualEventBase* tryGetVirtualEventBase();
void applyLoopKeepAlive();
......@@ -914,7 +906,7 @@ class EventBase : public TimeoutManager,
// A notification queue for runInEventBaseThread() to use
// to send function requests to the EventBase thread.
std::unique_ptr<EventBaseQueue> queue_;
std::unique_ptr<EventBaseAtomicNotificationQueue<Func, FuncRunner>> queue_;
ssize_t loopKeepAliveCount_{0};
std::atomic<ssize_t> loopKeepAliveCountAtomic_{0};
bool loopKeepAliveActive_{false};
......
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