code: public static void yield(long timeout) {
          long endtime = 0;
          if ( timeout > 0 ) {
              endtime = System.currentTimeMillis() + timeout;
          }
          if ( Thread.currentThread() instanceof DispatcherThread ) {
              DispatcherThread dt = (DispatcherThread) Thread.currentThread();
              Scheduler scheduler = dt.getScheduler();
              boolean term = false;
              int idleCount = 0;
              while ( ! term ) {
                  boolean hadSome = dt.pollQs();
                  if ( ! hadSome ) {
                      idleCount++;
                      scheduler.pollDelay(idleCount);
                      if ( endtime == 0 ) {
                          term = true;
                      }
                  } else {
                      idleCount = 0;
                  }
                  if ( endtime != 0 && System.currentTimeMillis() > endtime ) {
                      term = true;
                  }
              }
          } else {
              if ( timeout > 0 ) {
                  try {
                      Thread.sleep(timeout);
                  } catch (InterruptedException e) {
                      e.printStackTrace();
                  }
              }
          }
      }
docs: process messages on the mailbox/callback queue until timeout is reached. In case timeout is 0,
  process until mailbox+callback queue is empty.
  
  If called from a non-actor thread, either sleep until timeout or (if timeout == 0) its a NOP.
  
  @param timeout