Skip to content

Commit 39eae96

Browse files
j-piaseckifacebook-github-bot
authored andcommitted
RuntimeScheduler umbrella POC
Differential Revision: D107878704
1 parent 2271917 commit 39eae96

6 files changed

Lines changed: 82 additions & 47 deletions

File tree

packages/react-native/ReactCommon/react/renderer/runtimescheduler/CMakeLists.txt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,18 @@ add_library(react_renderer_runtimescheduler STATIC ${react_renderer_runtimesched
1313

1414
target_include_directories(react_renderer_runtimescheduler PUBLIC ${REACT_COMMON_DIR})
1515

16+
# POC: vend the umbrella as <React/RuntimeScheduler.h>. The umbrella physically
17+
# lives at this module's `React/` subdir, so adding the module dir as a public
18+
# include dir makes `<React/RuntimeScheduler.h>` resolve for dependents.
19+
# NOTE (macOS, case-insensitive FS): the `React/` prefix differs from the
20+
# existing lowercase `react/` tree only by case. They do not collide here (the
21+
# two RuntimeScheduler.h files sit at different depths), but this is a known
22+
# case-insensitive-FS fragility tracked in
23+
# __docs__/RuntimeSchedulerUmbrellaPOC.fb.md.
24+
# NOTE: adding the module dir also exposes the other headers as bare includes; a
25+
# real rollout would scope this to a dedicated public-include subdir.
26+
target_include_directories(react_renderer_runtimescheduler PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
27+
1628
target_link_libraries(react_renderer_runtimescheduler
1729
callinvoker
1830
jsi
@@ -29,7 +41,7 @@ target_compile_reactnative_options(react_renderer_runtimescheduler PRIVATE)
2941
target_compile_options(react_renderer_runtimescheduler PRIVATE -Wpedantic)
3042

3143
# POC (public C++ API surface reduction): this module exposes a single public
32-
# umbrella header, react/renderer/runtimescheduler/RuntimeScheduler.umbrella.h.
44+
# umbrella header, vended top-level as <React/RuntimeScheduler.h>.
3345
# Including any other module header directly is gated by an opt-in guard
3446
# (RuntimeSchedulerUmbrellaGuard.h) that is inert unless
3547
# REACT_RUNTIMESCHEDULER_ENFORCE_UMBRELLA is defined.

packages/react-native/ReactCommon/react/renderer/runtimescheduler/React-runtimescheduler.podspec

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,12 @@ Pod::Spec.new do |s|
3333
s.source = source
3434
s.source_files = podspec_sources("**/*.{cpp,h}", "**/*.h")
3535
s.header_dir = "react/renderer/runtimescheduler"
36-
s.exclude_files = "tests"
36+
# The umbrella is vended top-level as <React/RuntimeScheduler.h> via the
37+
# "Umbrella" subspec below, so exclude it from the main (react/...) mapping.
38+
s.exclude_files = ["tests", "React"]
3739
# POC (public C++ API surface reduction): RuntimeScheduler exposes a single
38-
# public umbrella header (RuntimeScheduler.umbrella.h). Including any other
39-
# module header directly is gated by an opt-in guard that is inert unless
40+
# public umbrella header, vended top-level as <React/RuntimeScheduler.h>.
41+
# Including any other module header directly is gated by an opt-in guard that is inert unless
4042
# REACT_RUNTIMESCHEDULER_ENFORCE_UMBRELLA is defined. CocoaPods exposes the
4143
# whole header_dir, so the individual headers remain includable here; the guard
4244
# macro is the only way to enforce "umbrella only" in the pods build.
@@ -69,4 +71,22 @@ Pod::Spec.new do |s|
6971
depend_on_js_engine(s)
7072
add_rn_third_party_dependencies(s)
7173
add_rncore_dependency(s)
74+
75+
# POC: vend the umbrella under the shared top-level `React/` prefix, i.e.
76+
# `#include <React/RuntimeScheduler.h>`. header_mappings_dir = "React" maps the
77+
# physical react/renderer/runtimescheduler/React/RuntimeScheduler.h to a
78+
# leaf-level RuntimeScheduler.h, and header_dir = "React" places it under React/.
79+
#
80+
# NOTE (untested): CocoaPods cannot be run in the internal build, so the exact
81+
# header_dir / header_mappings_dir interaction needs validation with `pod install`.
82+
# NOTE (macOS): under use_frameworks!, this pod's Headers would contain both
83+
# `React/` (umbrella) and `react/...` (interface headers); on a case-insensitive
84+
# filesystem those fold to one directory. They do not overwrite (different
85+
# depths), but this is a known fragility tracked in
86+
# __docs__/RuntimeSchedulerUmbrellaPOC.fb.md.
87+
s.subspec "Umbrella" do |ss|
88+
ss.source_files = "React/*.h"
89+
ss.header_dir = "React"
90+
ss.header_mappings_dir = "React"
91+
end
7292
end
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
#pragma once
9+
10+
// =============================================================================
11+
// Umbrella header for the `runtimescheduler` module — public entry point.
12+
//
13+
// POC (public C++ API surface reduction). Consumers include ONLY this header,
14+
// via the shared top-level `React/` prefix:
15+
//
16+
// #include <React/RuntimeScheduler.h>
17+
//
18+
// The individual interface headers below are re-exported here. The fork
19+
// implementations `RuntimeScheduler_Modern` / `RuntimeScheduler_Legacy` are
20+
// deliberately NOT included: they are private to the build unit.
21+
//
22+
// The `React/` prefix is a shared namespace (also used by React-Core's Obj-C
23+
// headers). Naming policy: one umbrella per module, named after the module, to
24+
// avoid leaf collisions in the shared namespace.
25+
//
26+
// NOTE: this file lives at `react/renderer/runtimescheduler/React/` so the
27+
// `<React/...>` include path can be produced physically (CMake) as well as via
28+
// header maps (Buck) and `header_dir` (CocoaPods). RN-internal code should keep
29+
// using the fine-grained `<react/renderer/runtimescheduler/...>` includes; only
30+
// outside consumers use this umbrella.
31+
// =============================================================================
32+
33+
// Mark that subsequent module headers are pulled in through the umbrella. This
34+
// satisfies the per-header umbrella guard (see RuntimeSchedulerUmbrellaGuard.h).
35+
#define REACT_RUNTIMESCHEDULER_UMBRELLA_INCLUDE
36+
37+
#include <react/renderer/runtimescheduler/RuntimeScheduler.h>
38+
#include <react/renderer/runtimescheduler/RuntimeSchedulerBinding.h>
39+
#include <react/renderer/runtimescheduler/RuntimeSchedulerCallInvoker.h>
40+
#include <react/renderer/runtimescheduler/RuntimeSchedulerEventTimingDelegate.h>
41+
#include <react/renderer/runtimescheduler/RuntimeSchedulerIntersectionObserverDelegate.h>
42+
#include <react/renderer/runtimescheduler/SchedulerPriorityUtils.h>
43+
#include <react/renderer/runtimescheduler/Task.h>
44+
#include <react/renderer/runtimescheduler/primitives.h>

packages/react-native/ReactCommon/react/renderer/runtimescheduler/RuntimeScheduler.umbrella.h

Lines changed: 0 additions & 41 deletions
This file was deleted.

packages/react-native/ReactCommon/react/renderer/runtimescheduler/tests/RuntimeSchedulerTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8+
#include <React/RuntimeScheduler.h>
89
#include <gtest/gtest.h>
910
#include <hermes/hermes.h>
1011
#include <jsi/jsi.h>
1112
#include <react/featureflags/ReactNativeFeatureFlags.h>
1213
#include <react/featureflags/ReactNativeFeatureFlagsDefaults.h>
1314
#include <react/performance/timeline/PerformanceEntryReporter.h>
14-
#include <react/renderer/runtimescheduler/RuntimeScheduler.umbrella.h>
1515
#include <chrono>
1616
#include <memory>
1717
#include <semaphore>

packages/react-native/ReactCommon/react/renderer/runtimescheduler/tests/SchedulerPriorityTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8+
#include <React/RuntimeScheduler.h>
89
#include <gtest/gtest.h>
9-
#include <react/renderer/runtimescheduler/RuntimeScheduler.umbrella.h>
1010
#include <chrono>
1111

1212
using namespace facebook::react;

0 commit comments

Comments
 (0)