mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
..
This commit is contained in:
parent
8655cf0193
commit
aa17c063a4
1 changed files with 7 additions and 5 deletions
|
|
@ -1,4 +1,4 @@
|
|||
use std::{io, ops::{Deref, DerefMut}};
|
||||
use std::{io, ops::{Deref, DerefMut}, time::Duration};
|
||||
|
||||
pub struct AsyncStdin {
|
||||
inner: std::io::StdinLock<'static>,
|
||||
|
|
@ -24,7 +24,7 @@ impl AsyncStdin {
|
|||
me
|
||||
}
|
||||
|
||||
pub fn poll(&mut self, timeout: std::time::Duration) -> std::io::Result<bool> {
|
||||
pub fn poll(&mut self, timeout: Duration) -> std::io::Result<bool> {
|
||||
use std::os::unix::io::AsRawFd;
|
||||
|
||||
let mut tv = libc::timeval {
|
||||
|
|
@ -66,10 +66,12 @@ impl AsyncStdin {
|
|||
impl AsyncStdin {
|
||||
pub fn new(inner: std::io::StdinLock<'static>) -> Self { Self { inner } }
|
||||
|
||||
pub fn poll(&mut self) -> std::io::Result<bool> {
|
||||
let handle = HANDLE(self.inner.as_raw_handle() as isize);
|
||||
pub fn poll(&mut self, timeout: Duration) -> std::io::Result<bool> {
|
||||
use std::os::windows::io::AsRawHandle;
|
||||
|
||||
match unsafe { WaitForSingleObject(handle, 5000) } {
|
||||
let handle = self.inner.as_raw_handle();
|
||||
let millis = timeout.as_millis();
|
||||
match unsafe { WaitForSingleObject(handle, millis) } {
|
||||
WAIT_TIMEOUT => Ok(false),
|
||||
_ => Ok(true),
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue