Fabric: `failCallback` implementation for MessageQueueEventBeat
Summary: See comments in the code. Reviewed By: mdvacca Differential Revision: D10081502 fbshipit-source-id: b55bf019346a44c4b2980c70f547f53e4994e968
This commit is contained in:
parent
fa3525dc83
commit
02d2e85af3
|
@ -41,10 +41,26 @@ void MessageQueueEventBeat::induce() const {
|
|||
return;
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
// We do a trick here.
|
||||
// If `wasExecuted` was destroyed before set to `true`,
|
||||
// it means that the execution block was deallocated not being executed.
|
||||
// This indicates that `messageQueueThread_` is being deallocated.
|
||||
auto wasExecuted = std::shared_ptr<bool>(new bool {false}, [this](bool *wasExecuted) {
|
||||
if (!*wasExecuted && failCallback_) {
|
||||
failCallback_();
|
||||
}
|
||||
delete wasExecuted;
|
||||
});
|
||||
#endif
|
||||
|
||||
isBusy_ = true;
|
||||
messageQueueThread_->runOnQueue([this]() {
|
||||
messageQueueThread_->runOnQueue([=]() mutable {
|
||||
this->beat();
|
||||
isBusy_ = false;
|
||||
#ifndef NDEBUG
|
||||
*wasExecuted = true;
|
||||
#endif
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue