Code example for Semaphore

Methods: availablePermits, release

0
		Bundle b = new Bundle();
		b.putBoolean("connection", false);
		Intent i = new Intent(CONNECTION_STATUS);
		i.putExtras(b);
		sendBroadcast(i, null);
		int inuse = TINYG_BUFFER_SIZE - serialBufferAvail.availablePermits();
		if (inuse > 0)
			serialBufferAvail.release(inuse);
		queue.clear();
		writeLock.release();
		if (dequeueWorker != null)
			dequeueWorker.interrupt();
		dequeueWorker = null;
		ioLog.close();
		Log.d(TAG, "disconnect done");
	} 
 
	public class TinyGBinder extends Binder {
		public TinyGService getService() { 
			return TinyGService.this;
		}