fn t_yield(&mut self) -> bool {
        let mut pos = self.current;
        while self.tasks[pos].state != State::Ready {
            pos += 1;
            if pos == self.tasks.len() {
                pos = 0;
            }
            if pos == self.current {
                return false;
            }
        }

        if self.tasks[self.current].state != State::Available {
            self.tasks[self.current].state = State::Ready;
        }

        self.tasks[pos].state = State::Running;
        let old_pos = self.current;
        self.current = pos;

        unsafe {
            switch(&mut self.tasks[old_pos].ctx, &self.tasks[pos].ctx);
        }

        // NOTE: this might look strange and it is. Normally we would just mark this as `unreachable!()` but our compiler
        // is too smart for it's own good so it optimized our code away on release builds. Curiously this happens on windows
        // and not on linux. This is a common problem in tests so Rust has a `black_box` function in the `test` crate that
        // will "pretend" to use a value we give it to prevent the compiler from eliminating code. I'll just do this instead,
        // this code will never be run anyways and if it did it would always be `true`.
        self.tasks.len() > 0
    }
/// This is the heart of our runtime. Here we go through all tasks and see if anyone is in the `Ready` state.
/// If no task is `Ready` we're all done. This is an extremely simple sceduler using only a round-robin algorithm.
///
/// If we find a task that's ready to be run we change the state of the current task from `Running` to `Ready`.
/// Then we call switch which will save the current context (the old context) and load the new context
/// into the CPU which then resumes based on the context it was just passed.
This is the heart of our runtime. Here we go through all tasks and see if anyone is in the `Ready` state.
If no task is `Ready` we're all done. This is an extremely simple sceduler using only a round-robin algorithm.

If we find a task that's ready to be run we change the state of the current task from `Running` to `Ready`.
Then we call switch which will save the current context (the old context) and load the new context
into the CPU which then resumes based on the context it was just passed.
This is the heart of our runtime . Here we go through all tasks and see if anyone is in the ` Ready ` state . If no task is ` Ready ` we ' re all done . This is an extremely simple sceduler using only a round - robin algorithm . If we find a task that ' s ready to be run we change the state of the current task from ` Running ` to ` Ready ` . Then we call switch which will save the current context ( the old context ) and load the new context into the CPU which then resumes based on the context it was just passed .
fn t_yield(&mut self) -> bool {
        let mut pos = self.current;
        while self.tasks[pos].state != State::Ready {
            pos += 1;
            if pos == self.tasks.len() {
                pos = 0;
            }
            if pos == self.current {
                return false;
            }
        }
        if self.tasks[self.current].state != State::Available {
            self.tasks[self.current].state = State::Ready;
        }
        self.tasks[pos].state = State::Running;
        let old_pos = self.current;
        self.current = pos;
        unsafe {
            switch(&mut self.tasks[old_pos].ctx, &self.tasks[pos].ctx);
        }
        // NOTE: this might look strange and it is. Normally we would just mark this as `unreachable!()` but our compiler
        // is too smart for it's own good so it optimized our code away on release builds. Curiously this happens on windows
        // and not on linux. This is a common problem in tests so Rust has a `black_box` function in the `test` crate that
        // will "pretend" to use a value we give it to prevent the compiler from eliminating code. I'll just do this instead,
        // this code will never be run anyways and if it did it would always be `true`.
        self.tasks.len() > 0
    }
fn t_yield ( & mut self ) -> bool { let mut pos = self . current ; while self . tasks [ pos ] . state != State :: Ready { pos += 1 ; if pos == self . tasks . len ( ) { pos = 0 ; } if pos == self . current { return false ; } } if self . tasks [ self . current ] . state != State :: Available { self . tasks [ self . current ] . state = State :: Ready ; } self . tasks [ pos ] . state = State :: Running ; let old_pos = self . current ; self . current = pos ; unsafe { switch ( & mut self . tasks [ old_pos ] . ctx , & self . tasks [ pos ] . ctx ) ; } // NOTE: this might look strange and it is. Normally we would just mark this as `unreachable!()` but our compiler // is too smart for it's own good so it optimized our code away on release builds. Curiously this happens on windows // and not on linux. This is a common problem in tests so Rust has a `black_box` function in the `test` crate that // will "pretend" to use a value we give it to prevent the compiler from eliminating code. I'll just do this instead, // this code will never be run anyways and if it did it would always be `true`. self . tasks . len ( ) > 0 }
This is the heart of our runtime.
This is the heart of our runtime .
&mut self
&mut self