-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
future: add proper synchronization when awaiting the future
Previously, there was a scenario when using `current-thread` tokio runtime, that caused the deadlock. The scenario described: ``` - we make use of a `current-thread` tokio runtime (`Builder::new_current_thread().enable_all().build()`) - we create a future which sleeps, let's say, 2s and then sets the value - we call `cass_future_wait_timed` on this future, with a timeout 1s. This consumes the handle, starts the future, times out after 1s (there is still a task to be polled until completion - the future from above which sets the value) - now we call `cass_future_wait` on the same future. This waits on cond variable (blocking operation). Now current thread is blocked, it is waiting (on a cond variable) for a value to be set. But there is noone to poll the future that sets the value, since we are using a `current-thread` runtime - deadlock... ``` This commit fixes that, preventing such scenario from happening. Co-authored-by: Karol Baryła <[email protected]>
- Loading branch information
Showing
1 changed file
with
91 additions
and
36 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