fn wait_for_fences<I>(&self, fences: I, wait: WaitFor, timeout_ms: u32) -> bool
    where
        I: IntoIterator,
        I::Item: Borrow<B::Fence>,
    {
        use std::{time, thread};
        let start = time::Instant::now();
        fn to_ms(duration: time::Duration) -> u32 {
            duration.as_secs() as u32 * 1000 + duration.subsec_nanos() / 1_000_000
        }
        match wait {
            WaitFor::All => {
                for fence in fences {
                    if !self.wait_for_fence(fence.borrow(), 0) {
                        let elapsed_ms = to_ms(start.elapsed());
                        if elapsed_ms > timeout_ms {
                            return false;
                        }
                        if !self.wait_for_fence(fence.borrow(), timeout_ms - elapsed_ms) {
                            return false;
                        }
                    }
                }
                true
            },
            WaitFor::Any => {
                let fences: Vec<_> = fences.into_iter().collect();
                loop {
                    for fence in &fences {
                        if self.wait_for_fence(fence.borrow(), 0) {
                            return true;
                        }
                    }
                    if to_ms(start.elapsed()) >= timeout_ms {
                        return false;
                    }
                    thread::sleep(time::Duration::from_millis(1));
                }
            }
        }
    }
/// Blocks until all or one of the given fences are signaled.
/// Returns true if fences were signaled before the timeout.
Blocks until all or one of the given fences are signaled.
Returns true if fences were signaled before the timeout.
Blocks until all or one of the given fences are signaled . Returns true if fences were signaled before the timeout .
fn wait_for_fences<I>(&self, fences: I, wait: WaitFor, timeout_ms: u32) -> bool
    where
        I: IntoIterator,
        I::Item: Borrow<B::Fence>,
    {
        use std::{time, thread};
        let start = time::Instant::now();
        fn to_ms(duration: time::Duration) -> u32 {
            duration.as_secs() as u32 * 1000 + duration.subsec_nanos() / 1_000_000
        }
        match wait {
            WaitFor::All => {
                for fence in fences {
                    if !self.wait_for_fence(fence.borrow(), 0) {
                        let elapsed_ms = to_ms(start.elapsed());
                        if elapsed_ms > timeout_ms {
                            return false;
                        }
                        if !self.wait_for_fence(fence.borrow(), timeout_ms - elapsed_ms) {
                            return false;
                        }
                    }
                }
                true
            },
            WaitFor::Any => {
                let fences: Vec<_> = fences.into_iter().collect();
                loop {
                    for fence in &fences {
                        if self.wait_for_fence(fence.borrow(), 0) {
                            return true;
                        }
                    }
                    if to_ms(start.elapsed()) >= timeout_ms {
                        return false;
                    }
                    thread::sleep(time::Duration::from_millis(1));
                }
            }
        }
    }
fn wait_for_fences < I > ( & self , fences : I , wait : WaitFor , timeout_ms : u32 ) -> bool where I : IntoIterator , I :: Item : Borrow < B :: Fence > , { use std :: { time , thread } ; let start = time :: Instant :: now ( ) ; fn to_ms ( duration : time :: Duration ) -> u32 { duration . as_secs ( ) as u32 * 1000 + duration . subsec_nanos ( ) / 1_000_000 } match wait { WaitFor :: All => { for fence in fences { if ! self . wait_for_fence ( fence . borrow ( ) , 0 ) { let elapsed_ms = to_ms ( start . elapsed ( ) ) ; if elapsed_ms > timeout_ms { return false ; } if ! self . wait_for_fence ( fence . borrow ( ) , timeout_ms - elapsed_ms ) { return false ; } } } true } , WaitFor :: Any => { let fences : Vec < _ > = fences . into_iter ( ) . collect ( ) ; loop { for fence in & fences { if self . wait_for_fence ( fence . borrow ( ) , 0 ) { return true ; } } if to_ms ( start . elapsed ( ) ) >= timeout_ms { return false ; } thread :: sleep ( time :: Duration :: from_millis ( 1 ) ) ; } } } }
Blocks until all or one of the given fences are signaled.
Blocks until all or one of the given fences are signaled .
&self
fences
I
wait
WaitFor
timeout_ms
u32