func (t *Semaphore) Resize(capacity int) {

	// only allow one resize to be called from one thread
	t.resizeMutex.Lock()

	if capacity == cap(t.s) {
		t.resizeMutex.Unlock()
		return
	}

	// lock the locks
	t.resizeLock()
	t.readMutex.Lock()
	defer t.resizeUnlock()
	defer t.resizeMutex.Unlock()
	defer t.readMutex.Unlock()

	new := make(chan struct{}, capacity) // create the new semaphore with the new capcity

	// copy the old values
	for n := len(t.s); n != 0; n = len(t.s) {
		new <- <-t.s // copy elements to the new channel
	}

	t.s = new
}
func (t *Semaphore) Resize(capacity int) {

	// only allow one resize to be called from one thread
	t.resizeMutex.Lock()

	if capacity == cap(t.s) {
		t.resizeMutex.Unlock()
		return
	}

	// lock the locks
	t.resizeLock()
	t.readMutex.Lock()
	defer t.resizeUnlock()
	defer t.resizeMutex.Unlock()
	defer t.readMutex.Unlock()

	new := make(chan struct{}, capacity) // create the new semaphore with the new capcity

	// copy the old values
	for n := len(t.s); n != 0; n = len(t.s) {
		new <- <-t.s // copy elements to the new channel
	}

	t.s = new
}
// Resize allows dynamic resizing of the semaphore, it can be used if it desired
// to increase the current number of allowable concurent processes.