Summary: This change isolates the usage of folly async from Flipper. Is now self-contained in Flipper Folly schedulers. Users of Flipper can decide not to use the types defined in that header and implement their own. NOTE: changes are minimal, we are just replacing direct calls to folly event base with a scheduler which simply relays this on to folly. Reviewed By: fabiomassimo Differential Revision: D36052198 fbshipit-source-id: 170d64a324a1f1f100224e2622a59cbac3c8b642
51 lines
1.4 KiB
C++
51 lines
1.4 KiB
C++
/*
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
#include "FlipperSocketProvider.h"
|
|
#include "FlipperSocket.h"
|
|
#include "FlipperTransportTypes.h"
|
|
|
|
namespace facebook {
|
|
namespace flipper {
|
|
|
|
std::unique_ptr<FlipperSocketProvider> FlipperSocketProvider::provider_ =
|
|
nullptr;
|
|
|
|
std::unique_ptr<FlipperSocketProvider> FlipperSocketProvider::shelvedProvider_ =
|
|
nullptr;
|
|
|
|
std::unique_ptr<FlipperSocket> FlipperSocketProvider::socketCreate(
|
|
FlipperConnectionEndpoint endpoint,
|
|
std::unique_ptr<FlipperSocketBasePayload> payload,
|
|
Scheduler* scheduler) {
|
|
return provider_->create(std::move(endpoint), std::move(payload), scheduler);
|
|
}
|
|
|
|
std::unique_ptr<FlipperSocket> FlipperSocketProvider::socketCreate(
|
|
FlipperConnectionEndpoint endpoint,
|
|
std::unique_ptr<FlipperSocketBasePayload> payload,
|
|
Scheduler* scheduler,
|
|
ConnectionContextStore* connectionContextStore) {
|
|
return provider_->create(
|
|
std::move(endpoint),
|
|
std::move(payload),
|
|
scheduler,
|
|
connectionContextStore);
|
|
}
|
|
|
|
void FlipperSocketProvider::setDefaultProvider(
|
|
std::unique_ptr<FlipperSocketProvider> provider) {
|
|
provider_ = std::move(provider);
|
|
}
|
|
|
|
bool FlipperSocketProvider::hasProvider() {
|
|
return provider_ != nullptr;
|
|
}
|
|
|
|
} // namespace flipper
|
|
} // namespace facebook
|