lock individual processes, not the whole queue

This commit is contained in:
Aidan Hahn 2019-05-23 22:13:57 -07:00
parent 4cb9d3a5e1
commit 213d48c087
No known key found for this signature in database
GPG key ID: 327711E983899316
3 changed files with 110 additions and 110 deletions

View file

@ -17,25 +17,28 @@ import java.util.concurrent.TimeoutException;
*/
class ProcessManagerTestImplementation extends ProcessManager {
public void longCallHoldsLock() {
public void longCallHoldsLock(int pid) {
try {
super.getLock();
super.getLock(pid);
System.err.println("[1] Long Call Has Lock");
// hold lock for 7 seconds, more than double normal timeout.
Thread.sleep(4000);
super.releaseLock();
super.releaseLock(pid);
} catch (TimeoutException e) {
System.err.println("[!!] Long Call wasnt able to grab lock!");
return;
} catch (InterruptedException e) {
super.releaseLock();
super.releaseLock(pid); // this doesnt happen, dont cancel this task
System.err.println("[3] Released lock: interrupted");
return;
}
}
public Boolean reportLockState(int pid) {
return super.lockMap.get(pid);
}
}