Files
react-native/ReactCommon/fabric/mounting/TelemetryController.h
T
Valentin Shergin 35f2cd26ae Fabric: Introducing TelemetryController as part of MountingManager
Summary:
This diff implements TelemetryController, a small tool that can be used to instrument mounting transactions. It abstracts the logic of merging telemetry data of multiple transactions in a thread-safe manner.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D22490580

fbshipit-source-id: 3f3425b88d38fddb555c1390fd8f1ff3ef1c475a
2020-07-15 23:30:33 -07:00

59 lines
1.5 KiB
C++

/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#pragma once
#include <functional>
#include <mutex>
#include <react/mounting/MountingTelemetry.h>
#include <react/mounting/MountingTransaction.h>
#include <react/mounting/MountingTransactionMetadata.h>
namespace facebook {
namespace react {
class MountingCoordinator;
/*
* Provides convenient tools for aggregating and accessing telemetry data
* associated with running Surface.
*/
class TelemetryController final {
friend class MountingCoordinator;
/*
* To be used by `MountingCoordinator`.
*/
TelemetryController(MountingCoordinator const &mountingCoordinator) noexcept;
/*
* Not copyable.
*/
TelemetryController(TelemetryController const &other) noexcept = delete;
TelemetryController &operator=(TelemetryController const &other) noexcept =
delete;
public:
/*
* Calls `MountingCoordinator::pullTransaction()` and aggregates telemetry.
*/
bool pullTransaction(
std::function<void(MountingTransactionMetadata metadata)> willMount,
std::function<void(ShadowViewMutationList const &mutations)> doMount,
std::function<void(MountingTransactionMetadata metadata)> didMount) const
noexcept;
private:
MountingCoordinator const &mountingCoordinator_;
mutable SurfaceTelemetry compoundTelemetry_{};
mutable std::mutex mutex_;
};
} // namespace react
} // namespace facebook