summaryrefslogtreecommitdiffstats
path: root/tokio/tests/fs_file_mocked.rs
diff options
context:
space:
mode:
authorCarl Lerche <me@carllerche.com>2020-10-09 10:02:55 -0700
committerGitHub <noreply@github.com>2020-10-09 10:02:55 -0700
commitafe535283c68dec40c5fc7a810445e8c2380880f (patch)
tree41c0271db0ffc39662fac9a0cc957dee216a2bef /tokio/tests/fs_file_mocked.rs
parentee597347c5e612611142ece09c79e55f2d243590 (diff)
fs: future proof `File` (#2930)
Changes inherent methods to take `&self` instead of `&mut self`. This brings the API in line with `std`. This patch is implemented by using a `tokio::sync::Mutex` to guard the internal `File` state. This is not an ideal implementation strategy doesn't make a big impact compared to having to dispatch operations to a background thread followed by a blocking syscall. In the future, the implementation can be improved as we explore async file-system APIs provided by the operating-system (iocp / io_uring). Closes #2927
Diffstat (limited to 'tokio/tests/fs_file_mocked.rs')
-rw-r--r--tokio/tests/fs_file_mocked.rs7
1 files changed, 5 insertions, 2 deletions
diff --git a/tokio/tests/fs_file_mocked.rs b/tokio/tests/fs_file_mocked.rs
index 2e7e8b7c..edb74a73 100644
--- a/tokio/tests/fs_file_mocked.rs
+++ b/tokio/tests/fs_file_mocked.rs
@@ -57,6 +57,9 @@ pub(crate) mod fs {
pub(crate) use crate::support::mock_pool::asyncify;
}
+pub(crate) mod sync {
+ pub(crate) use tokio::sync::Mutex;
+}
use fs::sys;
use tokio::prelude::*;
@@ -710,7 +713,7 @@ fn open_set_len_ok() {
let (mock, file) = sys::File::mock();
mock.set_len(123);
- let mut file = File::from_std(file);
+ let file = File::from_std(file);
let mut t = task::spawn(file.set_len(123));
assert_pending!(t.poll());
@@ -728,7 +731,7 @@ fn open_set_len_err() {
let (mock, file) = sys::File::mock();
mock.set_len_err(123);
- let mut file = File::from_std(file);
+ let file = File::from_std(file);
let mut t = task::spawn(file.set_len(123));
assert_pending!(t.poll());