Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: rename MessageQueueThread #6750

Merged
merged 7 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.swmansion.reanimated;
package com.swmansion.worklets;

import com.facebook.proguard.annotations.DoNotStrip;

@DoNotStrip
public class ReanimatedMessageQueueThread extends ReanimatedMessageQueueThreadBase {
public class WorkletsMessageQueueThread extends WorkletsMessageQueueThreadBase {
@Override
public boolean runOnQueue(Runnable runnable) {
return messageQueueThread.runOnQueue(runnable);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.swmansion.reanimated;
package com.swmansion.worklets;

import com.facebook.proguard.annotations.DoNotStrip;
import com.facebook.react.bridge.queue.MessageQueueThread;
Expand All @@ -14,10 +14,10 @@
// The only method that has changed is `quitSynchronous()` (see comment above
// function implementation for details).
@DoNotStrip
public abstract class ReanimatedMessageQueueThreadBase implements MessageQueueThread {
public abstract class WorkletsMessageQueueThreadBase implements MessageQueueThread {
protected final MessageQueueThreadImpl messageQueueThread;

public ReanimatedMessageQueueThreadBase() {
public WorkletsMessageQueueThreadBase() {
messageQueueThread =
MessageQueueThreadImpl.create(
MessageQueueThreadSpec.mainThreadSpec(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import com.facebook.react.module.annotations.ReactModule;
import com.facebook.soloader.SoLoader;
import com.swmansion.reanimated.NativeWorkletsModuleSpec;
import com.swmansion.reanimated.ReanimatedMessageQueueThread;
import java.util.Objects;

@ReactModule(name = WorkletsModule.NAME)
Expand All @@ -30,8 +29,7 @@ protected HybridData getHybridData() {
return mHybridData;
}

private final ReanimatedMessageQueueThread mMessageQueueThread =
new ReanimatedMessageQueueThread();
private final WorkletsMessageQueueThread mMessageQueueThread = new WorkletsMessageQueueThread();

/**
* @noinspection JavaJniMissingFunction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#endif

#import <worklets/WorkletRuntime/ReanimatedRuntime.h>
#import <worklets/apple/REAMessageThread.h>
#import <worklets/apple/WorkletsMessageThread.h>

#ifdef RCT_NEW_ARCH_ENABLED
#import <React/RCTBridge+Private.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#endif

#import <worklets/WorkletRuntime/ReanimatedRuntime.h>
#import <worklets/apple/REAMessageThread.h>
#import <worklets/apple/WorkletsMessageThread.h>

#ifdef RCT_NEW_ARCH_ENABLED
#import <React/RCTBridge+Private.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
namespace facebook {
namespace react {

class REAMessageThread : public RCTMessageThread {
class WorkletsMessageThread : public RCTMessageThread {
public:
using RCTMessageThread::RCTMessageThread;
virtual void quitSynchronous() override;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#import <worklets/apple/REAMessageThread.h>
#import <worklets/apple/WorkletsMessageThread.h>

#import <condition_variable>
#import <mutex>
Expand All @@ -11,9 +11,9 @@
namespace react {

// Essentially the same as RCTMessageThread, but with public fields.
struct REAMessageThreadPublic {
struct WorkletsMessageThreadPublic {
// I don't know why we need three vtables (if you know then feel free to#import
// <reanimated/apple/native/REAMessageThread.h> explain it instead of this message), but this is what makes the casts
// <worklets/apple/WorkletsMessageThread.h> explain it instead of this message), but this is what makes the casts
// in quitSynchronous() work correctly.
void *vtable1;
void *vtable2;
Expand All @@ -27,10 +27,10 @@
// is an assertion for that in the destructor of RCTMessageThread, but we have
// to override quitSynchronous() as it would quit the main looper and freeze
// the app.
void REAMessageThread::quitSynchronous()
void WorkletsMessageThread::quitSynchronous()
{
RCTMessageThread *rctThread = static_cast<RCTMessageThread *>(this);
REAMessageThreadPublic *rctThreadPublic = reinterpret_cast<REAMessageThreadPublic *>(rctThread);
WorkletsMessageThreadPublic *rctThreadPublic = reinterpret_cast<WorkletsMessageThreadPublic *>(rctThread);
rctThreadPublic->m_shutdown = true;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#import <React/RCTBridge+Private.h>
#import <worklets/WorkletRuntime/RNRuntimeWorkletDecorator.h>
#import <worklets/apple/REAMessageThread.h>
#import <worklets/apple/WorkletsMessageThread.h>
#import <worklets/apple/WorkletsModule.h>
#import <worklets/tools/SingleInstanceChecker.h>

Expand Down Expand Up @@ -36,7 +36,7 @@ @implementation WorkletsModule {
{
auto *bridge = self.bridge;
auto &rnRuntime = *(jsi::Runtime *)bridge.runtime;
auto jsQueue = std::make_shared<REAMessageThread>([NSRunLoop currentRunLoop], ^(NSError *error) {
auto jsQueue = std::make_shared<WorkletsMessageThread>([NSRunLoop currentRunLoop], ^(NSError *error) {
throw error;
});
nativeWorkletsModule_ = std::make_shared<NativeWorkletsModule>(std::string([valueUnpackerCode UTF8String]), jsQueue);
Expand Down
Loading