Skip to content

Commit

Permalink
Work on issue stephanenicolas#270
Browse files Browse the repository at this point in the history
  • Loading branch information
stephanenicolas authored and seva-ask committed Jun 11, 2014
1 parent 1894fab commit 2af4ea7
Showing 1 changed file with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1320,29 +1320,32 @@ public SpiceManagerCommand(SpiceManager spiceManager) {

@Override
public T call() {
synchronized (spiceManager) {
if (spiceManager.isStopped) {
try {
spiceManager.waitForServiceToBeBound();
if (spiceManager.spiceService == null) {
return null;
}

spiceManager.lockSendRequestsToService.lock();
try {
spiceManager.waitForServiceToBeBound();
if (spiceManager.spiceService == null) {
if (spiceManager.spiceService == null || spiceManager.isStopped) {
return null;
}
} catch (InterruptedException e) {
Ln.e(e, "Spice command %s couldn't bind to service.", getClass().getName());
}

try {
T result = executeWhenBound(spiceManager.spiceService);
successFull = true;
return result;
} catch (Exception e) {
Ln.e(e);
this.exception = e;
return null;
} finally {
spiceManager.lockSendRequestsToService.unlock();
}
} catch (InterruptedException e) {
Ln.e(e, "Spice command %s couldn't bind to service.", getClass().getName());
return null;
}

}

protected abstract T executeWhenBound(SpiceService service) throws Exception;
Expand Down

0 comments on commit 2af4ea7

Please sign in to comment.