pub fn next_process(&mut self) -> Option<LTerm> {
    let current_pid = self.current;
    if let Some(curr_pid) = current_pid {
      let timeslice_result = {
        let curr = self.lookup_pid(curr_pid).unwrap();
        assert_eq!(curr.current_queue, Queue::None);
        curr.timeslice_result
      };

      match timeslice_result {
        SliceResult::Yield |

        SliceResult::None => {
          self.queue(curr_pid);
          self.current = None
        },

        SliceResult::Finished => {
          let err = ProcessError::Exception(ExceptionType::Exit,
                                            gen_atoms::NORMAL);
          self.exit_process(curr_pid, err)
        },

        SliceResult::Exception => {
          let p_error = {
            let curr = self.lookup_pid(curr_pid).unwrap();
            assert!(curr.is_failed());
            curr.error
          };
          self.exit_process(curr_pid, p_error);
          self.current = None
        },

        SliceResult::Wait => {},
      }
    } // if self.current

    // Now try and find another process to run
    while self.current.is_none() {
      // TODO: monotonic clock
      // TODO: wait lists
      // TODO: network checks

      // See if any are waiting in realtime (high) priority queue
      let mut next_pid: Option<LTerm> = None;
      if !self.queue_high.is_empty() {
        next_pid = self.queue_high.pop_front()
      } else if self.advantage_count < NORMAL_ADVANTAGE {
        if !self.queue_normal.is_empty() {
          next_pid = self.queue_normal.pop_front()
        } else if !self.queue_low.is_empty() {
          next_pid = self.queue_low.pop_front()
        }
        self.advantage_count += 1;
      } else {
        if !self.queue_low.is_empty() {
          next_pid = self.queue_low.pop_front()
        } else if !self.queue_normal.is_empty() {
          next_pid = self.queue_normal.pop_front()
        }
        self.advantage_count = 0;
      };

      if next_pid.is_some() {
        let next_pid1 = next_pid.unwrap();
//        {
//          let next_p = self.lookup_pid(&next_pid1).unwrap();
//          println!("{} next() queue {}", module(), next_p.pid);
//        }

        self.current = Some(next_pid1)
      }
    }

    self.current
  }
/// Get another process from the run queue for this scheduler.
Get another process from the run queue for this scheduler.
Get another process from the run queue for this scheduler .
pub fn next_process(&mut self) -> Option<LTerm> {
    let current_pid = self.current;
    if let Some(curr_pid) = current_pid {
      let timeslice_result = {
        let curr = self.lookup_pid(curr_pid).unwrap();
        assert_eq!(curr.current_queue, Queue::None);
        curr.timeslice_result
      };
      match timeslice_result {
        SliceResult::Yield |
        SliceResult::None => {
          self.queue(curr_pid);
          self.current = None
        },
        SliceResult::Finished => {
          let err = ProcessError::Exception(ExceptionType::Exit,
                                            gen_atoms::NORMAL);
          self.exit_process(curr_pid, err)
        },
        SliceResult::Exception => {
          let p_error = {
            let curr = self.lookup_pid(curr_pid).unwrap();
            assert!(curr.is_failed());
            curr.error
          };
          self.exit_process(curr_pid, p_error);
          self.current = None
        },
        SliceResult::Wait => {},
      }
    } // if self.current
    // Now try and find another process to run
    while self.current.is_none() {
      // TODO: monotonic clock
      // TODO: wait lists
      // TODO: network checks
      // See if any are waiting in realtime (high) priority queue
      let mut next_pid: Option<LTerm> = None;
      if !self.queue_high.is_empty() {
        next_pid = self.queue_high.pop_front()
      } else if self.advantage_count < NORMAL_ADVANTAGE {
        if !self.queue_normal.is_empty() {
          next_pid = self.queue_normal.pop_front()
        } else if !self.queue_low.is_empty() {
          next_pid = self.queue_low.pop_front()
        }
        self.advantage_count += 1;
      } else {
        if !self.queue_low.is_empty() {
          next_pid = self.queue_low.pop_front()
        } else if !self.queue_normal.is_empty() {
          next_pid = self.queue_normal.pop_front()
        }
        self.advantage_count = 0;
      };
      if next_pid.is_some() {
        let next_pid1 = next_pid.unwrap();
//        {
//          let next_p = self.lookup_pid(&next_pid1).unwrap();
//          println!("{} next() queue {}", module(), next_p.pid);
//        }
        self.current = Some(next_pid1)
      }
    }
    self.current
  }
pub fn next_process ( & mut self ) -> Option < LTerm > { let current_pid = self . current ; if let Some ( curr_pid ) = current_pid { let timeslice_result = { let curr = self . lookup_pid ( curr_pid ) . unwrap ( ) ; assert_eq ! ( curr current_queue Queue None ) ; curr . timeslice_result } ; match timeslice_result { SliceResult :: Yield | SliceResult :: None => { self . queue ( curr_pid ) ; self . current = None } , SliceResult :: Finished => { let err = ProcessError :: Exception ( ExceptionType :: Exit , gen_atoms :: NORMAL ) ; self . exit_process ( curr_pid , err ) } , SliceResult :: Exception => { let p_error = { let curr = self . lookup_pid ( curr_pid ) . unwrap ( ) ; assert ! ( curr is_failed ( ) ) ; curr . error } ; self . exit_process ( curr_pid , p_error ) ; self . current = None } , SliceResult :: Wait => { } , } } // if self.current // Now try and find another process to run while self . current . is_none ( ) { // TODO: monotonic clock // TODO: wait lists // TODO: network checks // See if any are waiting in realtime (high) priority queue let mut next_pid : Option < LTerm > = None ; if ! self . queue_high . is_empty ( ) { next_pid = self . queue_high . pop_front ( ) } else if self . advantage_count < NORMAL_ADVANTAGE { if ! self . queue_normal . is_empty ( ) { next_pid = self . queue_normal . pop_front ( ) } else if ! self . queue_low . is_empty ( ) { next_pid = self . queue_low . pop_front ( ) } self . advantage_count += 1 ; } else { if ! self . queue_low . is_empty ( ) { next_pid = self . queue_low . pop_front ( ) } else if ! self . queue_normal . is_empty ( ) { next_pid = self . queue_normal . pop_front ( ) } self . advantage_count = 0 ; } ; if next_pid . is_some ( ) { let next_pid1 = next_pid . unwrap ( ) ; //        { //          let next_p = self.lookup_pid(&next_pid1).unwrap(); //          println!("{} next() queue {}", module(), next_p.pid); //        } self . current = Some ( next_pid1 ) } } self . current }
Get another process from the run queue for this scheduler.
Get another process from the run queue for this scheduler .
&mut self