diff --git a/xplat/Sonar/SonarWebSocketImpl.cpp b/xplat/Sonar/SonarWebSocketImpl.cpp index 343aa7956..eea0aeb90 100644 --- a/xplat/Sonar/SonarWebSocketImpl.cpp +++ b/xplat/Sonar/SonarWebSocketImpl.cpp @@ -8,6 +8,7 @@ #include "SonarWebSocketImpl.h" #include +#include #include #include #include @@ -92,15 +93,14 @@ class Responder : public rsocket::RSocketResponder { SonarWebSocketImpl::SonarWebSocketImpl(SonarInitConfig config) : deviceData_(config.deviceData), worker_(config.worker) {} +folly::IOExecutor* ioExecutor; + SonarWebSocketImpl::~SonarWebSocketImpl() { stop(); } void SonarWebSocketImpl::start() { - folly::makeFuture() - .via(worker_->getEventBase()) - .delayedUnsafe(std::chrono::milliseconds(0)) - .then([this]() { startSync(); }); + folly::makeFuture().via(ioExecutor).then([this]() { startSync(); }); } void SonarWebSocketImpl::startSync() { @@ -184,8 +184,8 @@ void SonarWebSocketImpl::connectSecurely() { void SonarWebSocketImpl::reconnect() { folly::makeFuture() - .via(worker_->getEventBase()) - .delayedUnsafe(std::chrono::seconds(reconnectIntervalSeconds)) + .via(ioExecutor) + .delayed(std::chrono::seconds(reconnectIntervalSeconds)) .then([this]() { startSync(); }); }