code: int get_command(final long tout) {
  	int ret;
  
  	// Wait on monitor
  	if (shared_cmd.cmd_pending == false && shared_cmd.trigger == false) {
  	    if (works.size() == 0) {
  		p_mon.wait_it();
  	    } else if (tout > 0) {
  		p_mon.wait_it(tout);
  	    }
  	}
  
  	// Test if it is a new command. If yes, copy its data locally
  	if (shared_cmd.cmd_pending == true) {
  	    local_cmd = shared_cmd;
  	    ret = POLL_COMMAND;
  	} else if (shared_cmd.trigger == true) {
  	    local_cmd = shared_cmd;
  	    ret = POLL_TRIGGER;
  	} else {
  	    ret = POLL_TIME_OUT;
  	}
  
  	return ret;
      }
docs: ===============================================================