RuntimeEventBeat.h 946 B

12345678910111213141516171819202122232425262728293031323334353637
  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. #include <CoreFoundation/CFRunLoop.h>
  8. #include <CoreFoundation/CoreFoundation.h>
  9. #include <react/core/EventBeat.h>
  10. #include <react/utils/RuntimeExecutor.h>
  11. namespace facebook {
  12. namespace react {
  13. /*
  14. * Event beat associated with JavaScript runtime.
  15. * The beat is called on `RuntimeExecutor`'s thread induced by the main thread
  16. * event loop.
  17. */
  18. class RuntimeEventBeat : public EventBeat {
  19. public:
  20. RuntimeEventBeat(
  21. EventBeat::SharedOwnerBox const &ownerBox,
  22. RuntimeExecutor runtimeExecutor);
  23. ~RuntimeEventBeat();
  24. void induce() const override;
  25. private:
  26. const RuntimeExecutor runtimeExecutor_;
  27. CFRunLoopObserverRef mainRunLoopObserver_;
  28. mutable std::atomic<bool> isBusy_{false};
  29. };
  30. } // namespace react
  31. } // namespace facebook