You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
use tokio::io::{self,AsyncWriteExt};use tokio::fs::File;#[tokio::main]asyncfnmain() -> io::Result<()>{letmut file = File::create("foo.txt").await?;
file.write_all(b"some bytes").await?;Ok(())}
It is correct if this is precisely the scenario at hand: we write, and we shutdown the runtime. However, one might get into non-deterministic troubles if one does not flush via shutdown before yielding the control:
For
write_all
, we have the following example:It is correct if this is precisely the scenario at hand: we write, and we shutdown the runtime. However, one might get into non-deterministic troubles if one does not flush via
shutdown
before yielding the control:The read after the write might find the file incomplete, as the background thread for the write might still be around.
The text was updated successfully, but these errors were encountered: