mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Summary: Changelog: [internal] This modifies the method to run microtasks in `RuntimeScheduler_Modern` to align a bit better with the spec. In this case, we'll check if we're already running microtasks when we call that method, and skip if that's the case. We're not currently calling this method recursively so this shouldn't really be a change with the current logic. Reviewed By: javache Differential Revision: D54302537 fbshipit-source-id: ef5e12e68e0c7f8c9258929609c050ef78e4cde5
37 lines
743 B
C++
37 lines
743 B
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.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <functional>
|
|
|
|
namespace facebook::react {
|
|
|
|
template <typename Lambda>
|
|
class OnScopeExit {
|
|
public:
|
|
explicit OnScopeExit(const Lambda&& lambda) noexcept
|
|
: lambda_(std::move(lambda)) {}
|
|
|
|
// Non-movable
|
|
OnScopeExit(const OnScopeExit&) = delete;
|
|
OnScopeExit(OnScopeExit&&) = delete;
|
|
|
|
// Non-copyable
|
|
OnScopeExit& operator=(const OnScopeExit&) = delete;
|
|
OnScopeExit& operator=(OnScopeExit&&) = delete;
|
|
|
|
~OnScopeExit() noexcept {
|
|
lambda_();
|
|
}
|
|
|
|
private:
|
|
Lambda lambda_;
|
|
};
|
|
|
|
} // namespace facebook::react
|