2018-08-27 07:21:06 -07:00
|
|
|
/**
|
2018-09-11 15:27:47 -07:00
|
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
2018-08-27 07:21:06 -07:00
|
|
|
*
|
|
|
|
* This source code is licensed under the MIT license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <CoreFoundation/CoreFoundation.h>
|
|
|
|
#include <CoreFoundation/CFRunLoop.h>
|
2018-11-10 14:19:08 -08:00
|
|
|
#include <react/uimanager/primitives.h>
|
|
|
|
#include <react/events/EventBeat.h>
|
2018-08-27 07:21:06 -07:00
|
|
|
|
|
|
|
namespace facebook {
|
|
|
|
namespace react {
|
|
|
|
|
|
|
|
/*
|
2018-11-06 10:58:49 -08:00
|
|
|
* Event beat associated with JavaScript runtime.
|
|
|
|
* The beat is called on `RuntimeExecutor`'s thread induced by the main thread
|
|
|
|
* event loop.
|
2018-08-27 07:21:06 -07:00
|
|
|
*/
|
2018-11-06 10:58:49 -08:00
|
|
|
class RuntimeEventBeat:
|
2018-08-27 07:21:06 -07:00
|
|
|
public EventBeat {
|
|
|
|
|
|
|
|
public:
|
2018-11-06 10:58:49 -08:00
|
|
|
RuntimeEventBeat(RuntimeExecutor runtimeExecutor);
|
|
|
|
~RuntimeEventBeat();
|
2018-08-27 07:21:06 -07:00
|
|
|
|
|
|
|
void induce() const override;
|
|
|
|
|
|
|
|
private:
|
2018-11-06 10:58:49 -08:00
|
|
|
const RuntimeExecutor runtimeExecutor_;
|
2018-08-27 07:21:06 -07:00
|
|
|
CFRunLoopObserverRef mainRunLoopObserver_;
|
|
|
|
mutable std::atomic<bool> isBusy_ {false};
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace react
|
|
|
|
} // namespace facebook
|