RCTMessageThread.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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. #import <string>
  8. #import <Foundation/Foundation.h>
  9. #import <React/RCTJavaScriptExecutor.h>
  10. #import <cxxreact/MessageQueueThread.h>
  11. namespace facebook {
  12. namespace react {
  13. class RCTMessageThread : public MessageQueueThread {
  14. public:
  15. RCTMessageThread(NSRunLoop *runLoop, RCTJavaScriptCompleteBlock errorBlock);
  16. ~RCTMessageThread() override;
  17. void runOnQueue(std::function<void()> &&) override;
  18. void runOnQueueSync(std::function<void()> &&) override;
  19. void quitSynchronous() override;
  20. void setRunLoop(NSRunLoop *runLoop);
  21. private:
  22. void tryFunc(const std::function<void()> &func);
  23. void runAsync(std::function<void()> func);
  24. void runSync(std::function<void()> func);
  25. CFRunLoopRef m_cfRunLoop;
  26. RCTJavaScriptCompleteBlock m_errorBlock;
  27. std::atomic_bool m_shutdown;
  28. };
  29. } // namespace react
  30. } // namespace facebook