@@ -12,7 +12,7 @@ use crate::future;
12
12
use crate :: io:: { self , Read , Seek , SeekFrom , Write } ;
13
13
use crate :: path:: Path ;
14
14
use crate :: prelude:: * ;
15
- use crate :: task:: { self , blocking , Context , Poll , Waker } ;
15
+ use crate :: task:: { self , spawn_blocking , Context , Poll , Waker } ;
16
16
17
17
/// An open file on the filesystem.
18
18
///
@@ -112,7 +112,7 @@ impl File {
112
112
/// ```
113
113
pub async fn open < P : AsRef < Path > > ( path : P ) -> io:: Result < File > {
114
114
let path = path. as_ref ( ) . to_owned ( ) ;
115
- let file = blocking :: spawn ( move || std:: fs:: File :: open ( & path) ) . await ?;
115
+ let file = spawn_blocking ( move || std:: fs:: File :: open ( & path) ) . await ?;
116
116
Ok ( File :: new ( file, true ) )
117
117
}
118
118
@@ -147,7 +147,7 @@ impl File {
147
147
/// ```
148
148
pub async fn create < P : AsRef < Path > > ( path : P ) -> io:: Result < File > {
149
149
let path = path. as_ref ( ) . to_owned ( ) ;
150
- let file = blocking :: spawn ( move || std:: fs:: File :: create ( & path) ) . await ?;
150
+ let file = spawn_blocking ( move || std:: fs:: File :: create ( & path) ) . await ?;
151
151
Ok ( File :: new ( file, true ) )
152
152
}
153
153
@@ -180,7 +180,7 @@ impl File {
180
180
} )
181
181
. await ?;
182
182
183
- blocking :: spawn ( move || state. file . sync_all ( ) ) . await
183
+ spawn_blocking ( move || state. file . sync_all ( ) ) . await
184
184
}
185
185
186
186
/// Synchronizes OS-internal buffered contents to disk.
@@ -216,7 +216,7 @@ impl File {
216
216
} )
217
217
. await ?;
218
218
219
- blocking :: spawn ( move || state. file . sync_data ( ) ) . await
219
+ spawn_blocking ( move || state. file . sync_data ( ) ) . await
220
220
}
221
221
222
222
/// Truncates or extends the file.
@@ -249,7 +249,7 @@ impl File {
249
249
} )
250
250
. await ?;
251
251
252
- blocking :: spawn ( move || state. file . set_len ( size) ) . await
252
+ spawn_blocking ( move || state. file . set_len ( size) ) . await
253
253
}
254
254
255
255
/// Reads the file's metadata.
@@ -268,7 +268,7 @@ impl File {
268
268
/// ```
269
269
pub async fn metadata ( & self ) -> io:: Result < Metadata > {
270
270
let file = self . file . clone ( ) ;
271
- blocking :: spawn ( move || file. metadata ( ) ) . await
271
+ spawn_blocking ( move || file. metadata ( ) ) . await
272
272
}
273
273
274
274
/// Changes the permissions on the file.
@@ -297,7 +297,7 @@ impl File {
297
297
/// ```
298
298
pub async fn set_permissions ( & self , perm : Permissions ) -> io:: Result < ( ) > {
299
299
let file = self . file . clone ( ) ;
300
- blocking :: spawn ( move || file. set_permissions ( perm) ) . await
300
+ spawn_blocking ( move || file. set_permissions ( perm) ) . await
301
301
}
302
302
}
303
303
@@ -692,7 +692,7 @@ impl LockGuard<State> {
692
692
self . register ( cx) ;
693
693
694
694
// Start a read operation asynchronously.
695
- blocking :: spawn ( move || {
695
+ spawn_blocking ( move || {
696
696
// Read some data from the file into the cache.
697
697
let res = {
698
698
let State { file, cache, .. } = & mut * self ;
@@ -801,7 +801,7 @@ impl LockGuard<State> {
801
801
self . register ( cx) ;
802
802
803
803
// Start a write operation asynchronously.
804
- blocking :: spawn ( move || {
804
+ spawn_blocking ( move || {
805
805
match ( & * self . file ) . write_all ( & self . cache ) {
806
806
Ok ( _) => {
807
807
// Switch to idle mode.
@@ -834,7 +834,7 @@ impl LockGuard<State> {
834
834
self . register ( cx) ;
835
835
836
836
// Start a flush operation asynchronously.
837
- blocking :: spawn ( move || {
837
+ spawn_blocking ( move || {
838
838
match ( & * self . file ) . flush ( ) {
839
839
Ok ( ( ) ) => {
840
840
// Mark the file as flushed.
0 commit comments