Skip to content

Commit a8a2ae9

Browse files
bors[bot]Stjepan Glavina
and
Stjepan Glavina
authored
Merge #157
157: More robust file implementation r=stjepang a=stjepang This is a reimplementation of the `File`s state machine. The previous implementation was simple and a bit naive. It was not fundamentally wrong but had surprises in some corner cases. For example, if an async read operation was started but we timed out on it, the file cursor would move even though we didn't complete the operation. The new implementation will move the cursor only when read/write operations complete successfully. There was also a deadlock hazard in the case where multiple tasks were concurrently reading or writing to the same file, in which case some task wakeups would be lost. This PR fixes the problem. A nice consequence of this PR: `futures-channel` is now unused, so we can remove it from the dependency list. Co-authored-by: Stjepan Glavina <[email protected]>
2 parents cc9e078 + 6ed0e85 commit a8a2ae9

File tree

4 files changed

+466
-457
lines changed

4 files changed

+466
-457
lines changed

Cargo.toml

+1-2
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,9 @@ unstable = []
2727
async-task = "1.0.0"
2828
cfg-if = "0.1.9"
2929
crossbeam-channel = "0.3.9"
30-
futures-channel-preview = "0.3.0-alpha.18"
3130
futures-core-preview = "0.3.0-alpha.18"
3231
futures-io-preview = "0.3.0-alpha.18"
33-
futures-timer = "0.3.0"
32+
futures-timer = "0.4.0"
3433
lazy_static = "1.3.0"
3534
log = { version = "0.4.8", features = ["kv_unstable"] }
3635
memchr = "2.2.1"

examples/print-file.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use async_std::io;
77
use async_std::prelude::*;
88
use async_std::task;
99

10-
const LEN: usize = 4 * 1024 * 1024; // 4 Mb
10+
const LEN: usize = 16 * 1024; // 16 Kb
1111

1212
fn main() -> io::Result<()> {
1313
let path = args().nth(1).expect("missing path argument");

0 commit comments

Comments
 (0)