Being serial shouldn't be much slower as we are blocked by the slowest stopper anyway
178973
def wait_for_instance_death(instance, opts={})
      wait_for_instance_status(:terminated, instance, opts) if instance.exists?
    rescue AWS::EC2::Errors::InvalidInstanceID::NotFound
    end
252627
public EventResultDisruptor waitForBlocking() {
		SequenceBarrier barrier = ringBuffer.newBarrier();
		try {
			long a = barrier.waitFor(waitAtSequence);
			if (ringBuffer != null)
				return ringBuffer.get(a);
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			barrier.alert();
		}
		return null;
	}
1196699
function() {
	this.ENL_PORT = 3610;
	this.BAUD = 115200;
	this.SERIAL_SEND_INTERVAL = 500; // ms

	this.initialized = false;
	this.dataCallback = function(){};
	this.sentCallback = function(){};
	this.dataCallbackSerial = function(){};
	this.sentCallbackSerial = function(){};

	this.serialCallback = function(){};
	this.params = {};
	this.port = null;
	this.device = null;
	this.is_discovering = false;
	this.discovery_timer_id = null;
	this.response_buffer = null;
	this.response_text = '';

	this.mAdapter = null;
}
1219311
def promote(self):
        
        with self.mutex:
            self.rwlock -= 1
            while self.rwlock != 0:
                self._writer_wait()
            self.rwlock = -1
958765
public void run() {
        while (!exiting) {
            if (!queue.isEmpty()) {
                // wait for a small interval before attempting next transmission
                try {
                    String data = queue.take();

                    if (serial.isOpen()) {
                        serial.write(data);
                        serial.flush();
                    }

                    Thread.sleep(delay);
                } catch (IOException ioe) {
                    ioe.printStackTrace();
                } catch (InterruptedException e) {
                    //e.printStackTrace();
                }
            }
        }
    }
1301709
def stop(self):
        
        self.publish.setsockopt(zmq.LINGER, 1)
        self.publish.close()
        return self
465285
def advance(self, blocksize):
        
        ts = self._read_frame(blocksize)

        self.raw_buffer.roll(-len(ts))
        self.raw_buffer[-len(ts):] = ts[:]
        self.read_pos += blocksize
        self.raw_buffer.start_time += blocksize
        return ts
19732
def flush(self, _force_lock=False):
        
        if self.closed:
            raise DxlError('attempt to flush a closed serial communication')

        with self.__force_lock(_force_lock) or self._serial_lock:
            self._serial.flushInput()
            self._serial.flushOutput()
914264
def cancel(self):
        """"""
        if self.started and not self.connected and not self.timedout:
            self.connect_watcher.stop()
            self.timeout_watcher.stop()
536082
def backward(self, speed=1):
        
        if isinstance(self.enable_device, DigitalOutputDevice):
            if speed not in (0, 1):
                raise ValueError(
                    'backward speed must be 0 or 1 with non-PWM Motors')
        self.enable_device.off()
        self.phase_device.on()
        self.enable_device.value = speed
800813
def forward(self, seconds, vx=5):
        
        self.vx = vx
        self.sleep(seconds)
        self.vx = 0
750220
def stop_sync(self):
        """"""

        if self.scanning:
            self.stop_scan()

        # Make a copy since this will change size as we disconnect
        con_copy = copy.copy(self._connections)

        for _, context in con_copy.items():
            self.disconnect_sync(context['connection_id'])

        self._command_task.stop()
        self._stream.stop()
        self._serial_port.close()

        self.stopped = True
429885
void waitBetweenFrames(int transDelayMS, long lastTransactionTimestamp) {

        // If a fixed delay has been set
        if (transDelayMS > 0) {
            ModbusUtil.sleep(transDelayMS);
        }
        else {
            // Make use we have a gap of 3.5 characters between adjacent requests
            // We have to do the calculations here because it is possible that the caller may have changed
            // the connection characteristics if they provided the connection instance
            int delay = getInterFrameDelay() / 1000;

            // How long since the last message we received
            long gapSinceLastMessage = (System.nanoTime() - lastTransactionTimestamp) / NS_IN_A_MS;
            if (delay > gapSinceLastMessage) {
                long sleepTime = delay - gapSinceLastMessage;

                ModbusUtil.sleep(sleepTime);

                if (logger.isDebugEnabled()) {
                    logger.debug("Waited between frames for {} ms", sleepTime);
                }
            }
        }
    }
916250
public void pleaseStop()
    {
    	if (stopRequired)
    		return;
    	
        stopRequired = true;
        try
        {
            if (receiver != null)
                receiver.close();
        }
        catch (JMSException e)
        {
        	ErrorTools.log(e, log);
        }
    }
131113
private void pauseOrResumeReading() {
        int bytesWaiting;
        synchronized (lock) {
            bytesWaiting = waitingAppends.values()
                    .stream()
                    .mapToInt(a -> a.getData().readableBytes())
                    .sum();
        }

        if (bytesWaiting > HIGH_WATER_MARK) {
            log.debug("Pausing writing from connection {}", connection);
            connection.pauseReading();
        }
        if (bytesWaiting < LOW_WATER_MARK) {
            log.trace("Resuming writing from connection {}", connection);
            connection.resumeReading();
        }
    }
1356388
def slowDown(self, vehID, speed, duration):
        
        self._connection._beginMessage(
            tc.CMD_SET_VEHICLE_VARIABLE, tc.CMD_SLOWDOWN, vehID, 1 + 4 + 1 + 8 + 1 + 4)
        self._connection._string += struct.pack(
            "!BiBdBi", tc.TYPE_COMPOUND, 2, tc.TYPE_DOUBLE, speed, tc.TYPE_INTEGER, duration)
        self._connection._sendExact()
516555
void lowerActiveGetCount( H2ONode h2o ) {
    assert _key.home();    // Only the HOME node for a key tracks replicas
    assert h2o != H2O.SELF;// Do not track self as a replica
    while( true ) {        // Repeat, in case racing GETs are bumping the counter
      int old = _rwlock.get(); // Read the lock-word
      assert old > 0;      // Since lowering, must be at least 1
      assert old != -1;    // Not write-locked, because we are an active reader
      assert _replicas.contains(h2o._unique_idx); // Self-bit is set
      if( RW_CAS(old,old-1,"rlock-") ) {
        if( old-1 == 0 )   // GET count fell to zero?
          synchronized( this ) { notifyAll(); } // Notify any pending blocked PUTs
        return;            // Repeat until count is lowered
      }
    }
  }