UNPKG

982 Btext/x-cView Raw
1/*
2 * Copyright (c) Facebook, Inc. and its 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#import <string>
9
10#import <Foundation/Foundation.h>
11
12#import <React/RCTJavaScriptExecutor.h>
13#import <cxxreact/MessageQueueThread.h>
14
15namespace facebook {
16namespace react {
17
18class RCTMessageThread : public MessageQueueThread {
19 public:
20 RCTMessageThread(NSRunLoop *runLoop, RCTJavaScriptCompleteBlock errorBlock);
21 ~RCTMessageThread() override;
22 void runOnQueue(std::function<void()>&&) override;
23 void runOnQueueSync(std::function<void()>&&) override;
24 void quitSynchronous() override;
25 void setRunLoop(NSRunLoop *runLoop);
26
27 private:
28 void tryFunc(const std::function<void()>& func);
29 void runAsync(std::function<void()> func);
30 void runSync(std::function<void()> func);
31
32 CFRunLoopRef m_cfRunLoop;
33 RCTJavaScriptCompleteBlock m_errorBlock;
34 std::atomic_bool m_shutdown;
35};
36
37}
38}