Commit 3066914f authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook Github Bot

In SemiFuture members, fix DCHECK of pointer types

Summary:
[Folly] In `SemiFuture` members, fix `DCHECK` of pointer types.

Use `nullptr !=` to avoid ` error: ISO C++ forbids comparison between pointer and integer`.

Closes #708.

Reviewed By: Orvid

Differential Revision: D6277832

fbshipit-source-id: 8f65065d5347c6ac407b99cb780c38935e901362
parent 72d6102e
...@@ -473,7 +473,7 @@ void SemiFuture<T>::boost_() { ...@@ -473,7 +473,7 @@ void SemiFuture<T>::boost_() {
if (auto e = this->getExecutor()) { if (auto e = this->getExecutor()) {
// We know in a SemiFuture that if we have an executor it should be // We know in a SemiFuture that if we have an executor it should be
// DeferredExecutor. Verify this in debug mode. // DeferredExecutor. Verify this in debug mode.
DCHECK(dynamic_cast<DeferredExecutor*>(e)); DCHECK(nullptr != dynamic_cast<DeferredExecutor*>(e));
auto ka = static_cast<DeferredExecutor*>(e)->getKeepAliveToken(); auto ka = static_cast<DeferredExecutor*>(e)->getKeepAliveToken();
static_cast<DeferredExecutor*>(e)->boost(); static_cast<DeferredExecutor*>(e)->boost();
...@@ -493,7 +493,7 @@ inline Future<T> SemiFuture<T>::via(Executor* executor, int8_t priority) && { ...@@ -493,7 +493,7 @@ inline Future<T> SemiFuture<T>::via(Executor* executor, int8_t priority) && {
if (oldExecutor && executor && (executor != oldExecutor)) { if (oldExecutor && executor && (executor != oldExecutor)) {
// We know in a SemiFuture that if we have an executor it should be // We know in a SemiFuture that if we have an executor it should be
// DeferredExecutor. Verify this in debug mode. // DeferredExecutor. Verify this in debug mode.
DCHECK(dynamic_cast<DeferredExecutor*>(this->getExecutor())); DCHECK(nullptr != dynamic_cast<DeferredExecutor*>(this->getExecutor()));
if (static_cast<DeferredExecutor*>(oldExecutor)) { if (static_cast<DeferredExecutor*>(oldExecutor)) {
executor->add([oldExecutorKA = oldExecutor->getKeepAliveToken()]() { executor->add([oldExecutorKA = oldExecutor->getKeepAliveToken()]() {
static_cast<DeferredExecutor*>(oldExecutorKA.get())->boost(); static_cast<DeferredExecutor*>(oldExecutorKA.get())->boost();
...@@ -520,7 +520,7 @@ SemiFuture<T>::defer(F&& func) && { ...@@ -520,7 +520,7 @@ SemiFuture<T>::defer(F&& func) && {
// We know in a SemiFuture that if we have an executor it should be // We know in a SemiFuture that if we have an executor it should be
// DeferredExecutor (either it was that way before, or we just created it). // DeferredExecutor (either it was that way before, or we just created it).
// Verify this in debug mode. // Verify this in debug mode.
DCHECK(dynamic_cast<DeferredExecutor*>(e)); DCHECK(nullptr != dynamic_cast<DeferredExecutor*>(e));
// Convert to a folly::future with a deferred executor // Convert to a folly::future with a deferred executor
// Will be low-cost if this is not a new executor as via optimises for that // Will be low-cost if this is not a new executor as via optimises for that
// case // case
......
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