mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
c80192c2ab
Summary: The purpose of `EventBeat` is handling an asynchronous callback to itself which is being delivered on some different thread. That brings a challenge of ensuring that the `EventBeat` object stays valid during the timeframe of callback execution. The concept of Owner helps with that. The owner is a shared pointer that retains (probably indirectly) the `EventBeat` object. To ensure the correctness of the call, `EventBeat` retains the owner (practically creating a retain cycle) during executing the callback. In case if the pointer to the owner already null, `EventBeat` skips executing the callback. It's impossible to retain itself directly or refer to the shared pointer to itself from a constructor. `OwnerBox` is designed to work around this issue; it allows to store the pointer later, right after the creation of some other object that owns an `EventBeat`. Reviewed By: JoshuaGross Differential Revision: D17128549 fbshipit-source-id: 7ed34fd865430975157fd362f51c4a3d64214430