added a test for Mutex properties of the locking system

This commit is contained in:
Aidan Hahn 2019-05-23 19:31:03 -07:00
parent f14265fe5b
commit 8a513164ab
No known key found for this signature in database
GPG key ID: 327711E983899316
4 changed files with 86 additions and 13 deletions

View file

@ -124,12 +124,12 @@ class ProcessController {
try {
this.input.close();
this.output.close();
this.outputScanner.close();
this.process.destroy();
} catch (IOException e) {
// streams already closed
}
process.destroy();
this.killedManually = true;
}
}

View file

@ -225,10 +225,11 @@ class ProcessManager {
/*
* getLock()
* Locks access to this.processQueue
* Waits for a predefined timeout period and then grabs the mutex
* Waits for a predefined timeout period for mutex to be avail.
* Synchronized so two things cannot grab lock at once.
* Throws TimeoutException when it fails to get the lock.
*/
private void getLock() throws TimeoutException {
protected synchronized void getLock() throws TimeoutException {
Future<Object> future = this.threadPool.submit(this.lockCallable);
try {
@ -266,7 +267,7 @@ class ProcessManager {
* releaseLock()
* releases mutex so other threads can operate on processqueue
*/
private void releaseLock() {
protected void releaseLock() {
this.processQueueMutex = false;
}