-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixup deadlock when hammering futures of a certain type (#88)
According to [The Big O of Code Reviews](https://www.egorand.dev/the-big-o-of-code-reviews/), this is a O(_n_) change. This PR moves the polling of futures to outside of the continuation callback; this has shown to be a source of deadlocks. ``` // From https://github.com/mozilla/uniffi-rs/pull/1837/files#diff-8a28c9cf1245b4f714d406ea4044d68e1000099928eaca1afb504ccbc008fe9fR35-R37 // // > WARNING: the call to [rust_future_poll] must be scheduled to happen soon after the callback is // > called, but not inside the callback itself. If [rust_future_poll] is called inside the // > callback, some futures will deadlock and our scheduler code might as well. // // This delay is to ensure that `uniffiFutureContinuationCallback` returns before the next poll, i.e. // so that the next poll is outside of this callback. // // The length of the delay seems to be significant (at least in tests which hammer a network). // I would like to understand this more: I am still seeing deadlocks when this drops below its current // delay, but these maybe related to a different issue, as alluded to in // mozilla/uniffi-rs#1901 ``` Unfortunately, the tests for this aren't likely to end up in this repo, since it relies on a fork of the matrix-sdk. As said in the comment, I'm don't think this has fixed all possible deadlocks, but I'm _hoping_ this has at least fixed the proximal problem. Fixes #89
- Loading branch information
Showing
4 changed files
with
42 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters