mirror of
https://github.com/aljazceru/turso.git
synced 2025-12-30 06:24:21 +01:00
- otherwise, in multi-threading environment, other thread can think that completion is finished and start execution - this can lead to violated assertions (for example, page must be loaded, but as callback is not executed yet assert will be fired) Failing scenario: 1. main thread wants to execute pread - so it schedule IO and return control to the caller 2. IO thread read data from the disk 3. IO thread executes complete(result) 4. complete func set result of the completion to Ok 5. main thread enter into the step loop again and check completion status 6. completion marked as finished/is_completed - so main thread continue execution 7. main thread check that page is loaded and fails with assertion - because it's not loaded yet 8. IO thread executed the callback and finished the completion Reviewed-by: Preston Thorpe <preston@turso.tech> Closes #2922