Commit f2c8ffe5 authored by Aaryaman Sagar's avatar Aaryaman Sagar Committed by Facebook Github Bot

assert the presence of the KeepAlive functionality with VirtualExecutor

Summary: title

Reviewed By: yfeldblum, andriigrynenko

Differential Revision: D8386575

fbshipit-source-id: c900c8692b10004f2d9fbd95fa8ca96b3b8517d2
parent 925aeb00
...@@ -158,6 +158,16 @@ class Executor { ...@@ -158,6 +158,16 @@ class Executor {
} }
protected: protected:
/**
* Returns true if the KeepAlive is constructed from an executor that does
* not support the keep alive ref-counting functionality
*/
template <typename ExecutorT>
static bool isKeepAliveDummy(const KeepAlive<ExecutorT>& keepAlive) {
return reinterpret_cast<intptr_t>(keepAlive.executorAndDummyFlag_) &
KeepAlive<ExecutorT>::kDummyFlag;
}
// Acquire a keep alive token. Should return false if keep-alive mechanism // Acquire a keep alive token. Should return false if keep-alive mechanism
// is not supported. // is not supported.
virtual bool keepAliveAcquire(); virtual bool keepAliveAcquire();
......
...@@ -32,7 +32,9 @@ namespace folly { ...@@ -32,7 +32,9 @@ namespace folly {
class VirtualExecutor : public DefaultKeepAliveExecutor { class VirtualExecutor : public DefaultKeepAliveExecutor {
public: public:
explicit VirtualExecutor(KeepAlive<> executor) explicit VirtualExecutor(KeepAlive<> executor)
: executor_(std::move(executor)) {} : executor_(std::move(executor)) {
assert(!isKeepAliveDummy(executor_));
}
explicit VirtualExecutor(Executor* executor) explicit VirtualExecutor(Executor* executor)
: VirtualExecutor(getKeepAliveToken(executor)) {} : VirtualExecutor(getKeepAliveToken(executor)) {}
......
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