@@ -12,7 +12,7 @@ use crate::future;
1212use crate :: io:: { self , Read , Seek , SeekFrom , Write } ;
1313use crate :: path:: Path ;
1414use crate :: prelude:: * ;
15- use crate :: task:: { self , blocking , Context , Poll , Waker } ;
15+ use crate :: task:: { self , spawn_blocking , Context , Poll , Waker } ;
1616
1717/// An open file on the filesystem.
1818///
@@ -112,7 +112,7 @@ impl File {
112112 /// ```
113113 pub async fn open < P : AsRef < Path > > ( path : P ) -> io:: Result < File > {
114114 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 ?;
116116 Ok ( File :: new ( file, true ) )
117117 }
118118
@@ -147,7 +147,7 @@ impl File {
147147 /// ```
148148 pub async fn create < P : AsRef < Path > > ( path : P ) -> io:: Result < File > {
149149 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 ?;
151151 Ok ( File :: new ( file, true ) )
152152 }
153153
@@ -180,7 +180,7 @@ impl File {
180180 } )
181181 . await ?;
182182
183- blocking :: spawn ( move || state. file . sync_all ( ) ) . await
183+ spawn_blocking ( move || state. file . sync_all ( ) ) . await
184184 }
185185
186186 /// Synchronizes OS-internal buffered contents to disk.
@@ -216,7 +216,7 @@ impl File {
216216 } )
217217 . await ?;
218218
219- blocking :: spawn ( move || state. file . sync_data ( ) ) . await
219+ spawn_blocking ( move || state. file . sync_data ( ) ) . await
220220 }
221221
222222 /// Truncates or extends the file.
@@ -249,7 +249,7 @@ impl File {
249249 } )
250250 . await ?;
251251
252- blocking :: spawn ( move || state. file . set_len ( size) ) . await
252+ spawn_blocking ( move || state. file . set_len ( size) ) . await
253253 }
254254
255255 /// Reads the file's metadata.
@@ -268,7 +268,7 @@ impl File {
268268 /// ```
269269 pub async fn metadata ( & self ) -> io:: Result < Metadata > {
270270 let file = self . file . clone ( ) ;
271- blocking :: spawn ( move || file. metadata ( ) ) . await
271+ spawn_blocking ( move || file. metadata ( ) ) . await
272272 }
273273
274274 /// Changes the permissions on the file.
@@ -297,7 +297,7 @@ impl File {
297297 /// ```
298298 pub async fn set_permissions ( & self , perm : Permissions ) -> io:: Result < ( ) > {
299299 let file = self . file . clone ( ) ;
300- blocking :: spawn ( move || file. set_permissions ( perm) ) . await
300+ spawn_blocking ( move || file. set_permissions ( perm) ) . await
301301 }
302302}
303303
@@ -692,7 +692,7 @@ impl LockGuard<State> {
692692 self . register ( cx) ;
693693
694694 // Start a read operation asynchronously.
695- blocking :: spawn ( move || {
695+ spawn_blocking ( move || {
696696 // Read some data from the file into the cache.
697697 let res = {
698698 let State { file, cache, .. } = & mut * self ;
@@ -801,7 +801,7 @@ impl LockGuard<State> {
801801 self . register ( cx) ;
802802
803803 // Start a write operation asynchronously.
804- blocking :: spawn ( move || {
804+ spawn_blocking ( move || {
805805 match ( & * self . file ) . write_all ( & self . cache ) {
806806 Ok ( _) => {
807807 // Switch to idle mode.
@@ -834,7 +834,7 @@ impl LockGuard<State> {
834834 self . register ( cx) ;
835835
836836 // Start a flush operation asynchronously.
837- blocking :: spawn ( move || {
837+ spawn_blocking ( move || {
838838 match ( & * self . file ) . flush ( ) {
839839 Ok ( ( ) ) => {
840840 // Mark the file as flushed.
0 commit comments