Skip to content

Commit cb797b8

Browse files
authored
chore(Worklets): add RuntimeId type alias (#9026)
## Summary You don't need to remember the type now. ## Test plan 🚀
1 parent c0b9db7 commit cb797b8

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

packages/react-native-worklets/Common/cpp/worklets/WorkletRuntime/RuntimeData.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
#pragma once
22

33
#include <jsi/jsi.h>
4+
45
#include <string>
56

67
namespace worklets {
78
namespace RuntimeData {
89

10+
using RuntimeId = uint64_t;
11+
912
/**
1013
* Unused, but kept for possible future use.
1114
*/
12-
constexpr uint64_t rnRuntimeId{1};
13-
constexpr uint64_t uiRuntimeId{2};
15+
constexpr RuntimeId rnRuntimeId{1};
16+
constexpr RuntimeId uiRuntimeId{2};
1417
extern const std::string uiRuntimeName;
1518

1619
#if REACT_NATIVE_MINOR_VERSION >= 81

packages/react-native-worklets/Common/cpp/worklets/WorkletRuntime/WorkletRuntime.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ class WorkletRuntime : public jsi::HostObject, public std::enable_shared_from_th
120120
return *runtime_;
121121
}
122122

123-
[[nodiscard]] uint64_t getRuntimeId() const noexcept {
123+
[[nodiscard]] RuntimeData::RuntimeId getRuntimeId() const noexcept {
124124
return runtimeId_;
125125
}
126126

@@ -129,7 +129,7 @@ class WorkletRuntime : public jsi::HostObject, public std::enable_shared_from_th
129129
}
130130

131131
explicit WorkletRuntime(
132-
uint64_t runtimeId,
132+
RuntimeData::RuntimeId runtimeId,
133133
const std::shared_ptr<MessageQueueThread> &jsQueue,
134134
const std::string &name,
135135
const std::shared_ptr<AsyncQueue> &queue = nullptr,
@@ -173,7 +173,7 @@ class WorkletRuntime : public jsi::HostObject, public std::enable_shared_from_th
173173
#endif // NDEBUG
174174

175175
private:
176-
const uint64_t runtimeId_;
176+
const RuntimeData::RuntimeId runtimeId_;
177177
const std::shared_ptr<std::recursive_mutex> runtimeMutex_;
178178
const std::shared_ptr<jsi::Runtime> runtime_;
179179
const std::string name_;

0 commit comments

Comments
 (0)