-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Async lock + waitFor #9
Comments
I think a better design might be to do something which is based on message passing (e.g. you have a single writer which other isolates send messages asking it to write the data). It is not a good idea to use a low-level synchronous mutex in a place like this to begin with because attempt to grab a lock will completely block the caller if lock is already taken. You can concoct an asynchronous mutex out of existing synchronous mutex and ports. Here is the sketch with few missing details:
|
Hello!
Thank you for the simple and great library. I was considering using it as a way to synchronize writes to a SQLite database from different isolates, since SQLite only supports one writer at a time. Context: simolus3/drift#2760
The problem is that the SQLite library is async, but
runLocked
doesn't work with async callbacks as stated in the docs.I managed to "solve" it (at least for my simple demo) by creating an async
runLocked
+waitFor
. The problem is thatwaitFor
is being removed in Dart 3.3.How could this be solved in an alternative manner without the
waitFor
?Thank you!
Demo:
The text was updated successfully, but these errors were encountered: