MainRunLoopEventBeat.h 931 B

123456789101112131415161718192021222324252627282930313233343536373839
  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. #pragma once
  8. #include <CoreFoundation/CFRunLoop.h>
  9. #include <CoreFoundation/CoreFoundation.h>
  10. #include <react/core/EventBeat.h>
  11. #include <react/utils/RuntimeExecutor.h>
  12. namespace facebook {
  13. namespace react {
  14. /*
  15. * Event beat associated with main run loop cycle.
  16. * The callback is always called on the main thread.
  17. */
  18. class MainRunLoopEventBeat final : public EventBeat {
  19. public:
  20. MainRunLoopEventBeat(
  21. EventBeat::SharedOwnerBox const &ownerBox,
  22. RuntimeExecutor runtimeExecutor);
  23. ~MainRunLoopEventBeat();
  24. void induce() const override;
  25. private:
  26. void lockExecutorAndBeat() const;
  27. const RuntimeExecutor runtimeExecutor_;
  28. CFRunLoopObserverRef mainRunLoopObserver_;
  29. };
  30. } // namespace react
  31. } // namespace facebook