Skip to content

Commit

Permalink
Formatting was wrong
Browse files Browse the repository at this point in the history
  • Loading branch information
Davide Mazzoleni committed Jul 22, 2016
1 parent 68f5e57 commit 01daca2
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions workspace/popjava/src/popjava/jobmanager/RoundRobinAllocator.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,35 +23,39 @@ public class RoundRobinAllocator extends POPObject implements ResourceAllocator

private final AtomicInteger currentHost = new AtomicInteger();

private final Semaphore await = new Semaphore(0, true);
private final Semaphore await = new Semaphore(0, true);

@POPObjectDescription(url = "localhost")
public RoundRobinAllocator() {
services = new LinkedList<>();
services = new LinkedList<>();
}

@Override
@POPSyncSeq
@POPSyncSeq
public ServiceConnector getNextHost(ObjectDescriptionInput od) {
if(services.isEmpty())
if (services.isEmpty()) {
try {
await.acquire();
} catch (InterruptedException ex) { }

} catch (InterruptedException ex) {
}
}

// out of bound, go to first service
if(currentHost.get() >= services.size())
if (currentHost.get() >= services.size()) {
currentHost.set(0);
}

// linear allocation
return services.get(currentHost.getAndIncrement());
// linear allocation
return services.get(currentHost.getAndIncrement());
}

@Override
@POPSyncConc
@POPSyncConc
public void registerService(ServiceConnector service) {
if(services.isEmpty())
if (services.isEmpty()) {
await.release();
services.add(service);
}
services.add(service);
}

}

0 comments on commit 01daca2

Please sign in to comment.