mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-05 17:30:38 +08:00
Fabric: Introducting EventBeat::setFailCallback
Summary: In some cases we have to have a way to notify a EventBeat consumer that the beat cannot be (and will not be) delivered, so we introducing special API for that. Reviewed By: mdvacca Differential Revision: D10081503 fbshipit-source-id: 4c5a392d32572f426e3744bdba797efcd29b8cb4
This commit is contained in:
committed by
Facebook Github Bot
parent
9955aaf6be
commit
fa3525dc83
@@ -34,5 +34,9 @@ void EventBeat::setBeatCallback(const BeatCallback &beatCallback) {
|
||||
beatCallback_ = beatCallback;
|
||||
}
|
||||
|
||||
void EventBeat::setFailCallback(const FailCallback &failCallback) {
|
||||
failCallback_ = failCallback;
|
||||
}
|
||||
|
||||
} // namespace react
|
||||
} // namespace facebook
|
||||
|
||||
@@ -24,6 +24,7 @@ public:
|
||||
virtual ~EventBeat() = default;
|
||||
|
||||
using BeatCallback = std::function<void()>;
|
||||
using FailCallback = std::function<void()>;
|
||||
|
||||
/*
|
||||
* Communicates to the Beat that a consumer is waiting for the coming beat.
|
||||
@@ -44,11 +45,19 @@ public:
|
||||
virtual void induce() const;
|
||||
|
||||
/*
|
||||
* Sets a callback function.
|
||||
* Sets the beat callback function.
|
||||
* The callback is must be called on the proper thread.
|
||||
*/
|
||||
void setBeatCallback(const BeatCallback &beatCallback);
|
||||
|
||||
/*
|
||||
* Sets the fail callback function.
|
||||
* Called in case if the beat cannot be performed anymore because of
|
||||
* some external circumstances (e.g. execution thread is beling destructed).
|
||||
* The callback can be called on any thread.
|
||||
*/
|
||||
void setFailCallback(const FailCallback &failCallback);
|
||||
|
||||
protected:
|
||||
/*
|
||||
* Should be used by sublasses to send a beat.
|
||||
@@ -57,6 +66,7 @@ protected:
|
||||
void beat() const;
|
||||
|
||||
BeatCallback beatCallback_;
|
||||
FailCallback failCallback_;
|
||||
mutable std::atomic<bool> isRequested_ {false};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user