Back out "[sonar] Stop using folly Future::delayedUnsafe()"

Summary: Original commit changeset: 51ab3224b93e

Reviewed By: priteshrnandgaonkar

Differential Revision: D8676855

fbshipit-source-id: 38282f642d8497ce7715017127368445132454fa
This commit is contained in:
John Knox
2018-06-28 04:26:26 -07:00
committed by Facebook Github Bot
parent fc184812f6
commit f8c79b55dc

View File

@@ -8,7 +8,6 @@
#include "SonarWebSocketImpl.h" #include "SonarWebSocketImpl.h"
#include <folly/String.h> #include <folly/String.h>
#include <folly/executors/IOExecutor.h>
#include <folly/futures/Future.h> #include <folly/futures/Future.h>
#include <folly/io/async/SSLContext.h> #include <folly/io/async/SSLContext.h>
#include <folly/json.h> #include <folly/json.h>
@@ -93,14 +92,15 @@ class Responder : public rsocket::RSocketResponder {
SonarWebSocketImpl::SonarWebSocketImpl(SonarInitConfig config) SonarWebSocketImpl::SonarWebSocketImpl(SonarInitConfig config)
: deviceData_(config.deviceData), worker_(config.worker) {} : deviceData_(config.deviceData), worker_(config.worker) {}
folly::IOExecutor* ioExecutor;
SonarWebSocketImpl::~SonarWebSocketImpl() { SonarWebSocketImpl::~SonarWebSocketImpl() {
stop(); stop();
} }
void SonarWebSocketImpl::start() { void SonarWebSocketImpl::start() {
folly::makeFuture().via(ioExecutor).then([this]() { startSync(); }); folly::makeFuture()
.via(worker_->getEventBase())
.delayedUnsafe(std::chrono::milliseconds(0))
.then([this]() { startSync(); });
} }
void SonarWebSocketImpl::startSync() { void SonarWebSocketImpl::startSync() {
@@ -184,8 +184,8 @@ void SonarWebSocketImpl::connectSecurely() {
void SonarWebSocketImpl::reconnect() { void SonarWebSocketImpl::reconnect() {
folly::makeFuture() folly::makeFuture()
.via(ioExecutor) .via(worker_->getEventBase())
.delayed(std::chrono::seconds(reconnectIntervalSeconds)) .delayedUnsafe(std::chrono::seconds(reconnectIntervalSeconds))
.then([this]() { startSync(); }); .then([this]() { startSync(); });
} }