Skip to content

Commit

Permalink
pool: Allow mover queues with zero capacity
Browse files Browse the repository at this point in the history
PoolV4#mover_set_max_active allows the queue capacity to be set
to zero, yet the AdjustableSemaphore rejects this value (even
though the default capacity for a newly created semaphore is
zero).

Target: trunk
Require-book: no
Require-notes: yes
Acked-by: Paul Millar <paul.millar@desy.de>
Patch: http://rb.dcache.org/r/5425/
  • Loading branch information
gbehrmann committed Apr 10, 2013
1 parent 96f2b78 commit e3358e1
Showing 1 changed file with 5 additions and 4 deletions.
@@ -1,8 +1,12 @@
package org.dcache.util;

import com.google.common.base.Preconditions;

import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;

import static com.google.common.base.Preconditions.*;

/**
* A simple implementation of an adjustable semaphore.
*
Expand Down Expand Up @@ -44,10 +48,7 @@ public AdjustableSemaphore() {
* @param newMax
*/
public synchronized void setMaxPermits(int newMax) {
if (newMax < 1) {
throw new IllegalArgumentException("Semaphore size must be at least 1,"
+ " was " + newMax);
}
checkArgument(newMax >= 0);

int delta = newMax - this.maxPermits;

Expand Down

0 comments on commit e3358e1

Please sign in to comment.