Skip to content

Commit

Permalink
Yield the thread when waiting to delete a file
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisDenton committed Apr 28, 2022
1 parent 8dc4696 commit d579665
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions library/std/src/sys/windows/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use crate::sys::handle::Handle;
use crate::sys::time::SystemTime;
use crate::sys::{c, cvt};
use crate::sys_common::{AsInner, FromInner, IntoInner};
use crate::thread;

use super::path::maybe_verbatim;
use super::to_u16s;
Expand Down Expand Up @@ -1059,6 +1060,7 @@ fn remove_dir_all_iterative(f: &File, delete: fn(&File) -> io::Result<()>) -> io
// Otherwise return the error.
Err(e) => return Err(e),
}
thread::yield_now();
}
}
}
Expand All @@ -1072,6 +1074,7 @@ fn remove_dir_all_iterative(f: &File, delete: fn(&File) -> io::Result<()>) -> io
if i == MAX_RETRIES || e.kind() != io::ErrorKind::DirectoryNotEmpty {
return Err(e);
}
thread::yield_now();
} else {
break;
}
Expand Down

0 comments on commit d579665

Please sign in to comment.