From d018aeb32a0fcfba43b39c079b00922bd64c68ea Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 12 Aug 2024 14:54:03 -0700 Subject: [PATCH 1/3] . --- main/client/src/mill/main/client/lock/FileLocked.java | 2 +- main/client/src/mill/main/client/lock/FileTryLocked.java | 2 +- main/client/src/mill/main/client/lock/MemoryLocked.java | 2 +- main/client/src/mill/main/client/lock/MemoryTryLocked.java | 2 +- main/client/src/mill/main/client/lock/TryLocked.java | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/main/client/src/mill/main/client/lock/FileLocked.java b/main/client/src/mill/main/client/lock/FileLocked.java index 5fcba8b6c4d..ae31613278b 100644 --- a/main/client/src/mill/main/client/lock/FileLocked.java +++ b/main/client/src/mill/main/client/lock/FileLocked.java @@ -2,7 +2,7 @@ class FileLocked implements Locked { - protected java.nio.channels.FileLock lock; + final protected java.nio.channels.FileLock lock; public FileLocked(java.nio.channels.FileLock lock) { this.lock = lock; diff --git a/main/client/src/mill/main/client/lock/FileTryLocked.java b/main/client/src/mill/main/client/lock/FileTryLocked.java index e9182443a08..42e632f94a0 100644 --- a/main/client/src/mill/main/client/lock/FileTryLocked.java +++ b/main/client/src/mill/main/client/lock/FileTryLocked.java @@ -1,6 +1,6 @@ package mill.main.client.lock; -public class FileTryLocked extends FileLocked implements TryLocked{ +class FileTryLocked extends FileLocked implements TryLocked{ public FileTryLocked(java.nio.channels.FileLock lock) { super(lock); } diff --git a/main/client/src/mill/main/client/lock/MemoryLocked.java b/main/client/src/mill/main/client/lock/MemoryLocked.java index 76cb91a09a3..37bdc3cb625 100644 --- a/main/client/src/mill/main/client/lock/MemoryLocked.java +++ b/main/client/src/mill/main/client/lock/MemoryLocked.java @@ -2,7 +2,7 @@ class MemoryLocked implements Locked { - protected java.util.concurrent.locks.Lock lock; + final protected java.util.concurrent.locks.Lock lock; public MemoryLocked(java.util.concurrent.locks.Lock lock) { this.lock = lock; diff --git a/main/client/src/mill/main/client/lock/MemoryTryLocked.java b/main/client/src/mill/main/client/lock/MemoryTryLocked.java index 6063df59aa1..4a0ec840dee 100644 --- a/main/client/src/mill/main/client/lock/MemoryTryLocked.java +++ b/main/client/src/mill/main/client/lock/MemoryTryLocked.java @@ -1,6 +1,6 @@ package mill.main.client.lock; -public class MemoryTryLocked extends MemoryLocked implements TryLocked { +class MemoryTryLocked extends MemoryLocked implements TryLocked { public MemoryTryLocked(java.util.concurrent.locks.Lock lock) { super(lock); } diff --git a/main/client/src/mill/main/client/lock/TryLocked.java b/main/client/src/mill/main/client/lock/TryLocked.java index bc9d96368f3..14491a96c71 100644 --- a/main/client/src/mill/main/client/lock/TryLocked.java +++ b/main/client/src/mill/main/client/lock/TryLocked.java @@ -1,5 +1,5 @@ package mill.main.client.lock; public interface TryLocked extends Locked { - public boolean isLocked(); + boolean isLocked(); } From 59f9db4b42f4766825bb65d343f744aa023a877e Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 12 Aug 2024 14:54:53 -0700 Subject: [PATCH 2/3] . --- main/client/src/mill/main/client/lock/FileLocked.java | 2 +- main/client/src/mill/main/client/lock/MemoryLocked.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/main/client/src/mill/main/client/lock/FileLocked.java b/main/client/src/mill/main/client/lock/FileLocked.java index ae31613278b..5fcba8b6c4d 100644 --- a/main/client/src/mill/main/client/lock/FileLocked.java +++ b/main/client/src/mill/main/client/lock/FileLocked.java @@ -2,7 +2,7 @@ class FileLocked implements Locked { - final protected java.nio.channels.FileLock lock; + protected java.nio.channels.FileLock lock; public FileLocked(java.nio.channels.FileLock lock) { this.lock = lock; diff --git a/main/client/src/mill/main/client/lock/MemoryLocked.java b/main/client/src/mill/main/client/lock/MemoryLocked.java index 37bdc3cb625..76cb91a09a3 100644 --- a/main/client/src/mill/main/client/lock/MemoryLocked.java +++ b/main/client/src/mill/main/client/lock/MemoryLocked.java @@ -2,7 +2,7 @@ class MemoryLocked implements Locked { - final protected java.util.concurrent.locks.Lock lock; + protected java.util.concurrent.locks.Lock lock; public MemoryLocked(java.util.concurrent.locks.Lock lock) { this.lock = lock; From b9e918619322019da1ac41b294ac4f1ce2a48d15 Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 12 Aug 2024 14:57:45 -0700 Subject: [PATCH 3/3] . --- .../src/mill/main/client/lock/FileLock.java | 4 +-- .../src/mill/main/client/lock/FileLocked.java | 2 +- .../src/mill/main/client/lock/Locks.java | 34 +++++++++++-------- .../src/mill/main/client/lock/MemoryLock.java | 2 +- .../mill/main/client/lock/MemoryLocked.java | 2 +- 5 files changed, 25 insertions(+), 19 deletions(-) diff --git a/main/client/src/mill/main/client/lock/FileLock.java b/main/client/src/mill/main/client/lock/FileLock.java index eaae2135913..a405bc03c13 100644 --- a/main/client/src/mill/main/client/lock/FileLock.java +++ b/main/client/src/mill/main/client/lock/FileLock.java @@ -5,8 +5,8 @@ class FileLock extends Lock { - private RandomAccessFile raf; - private FileChannel chan; + final private RandomAccessFile raf; + final private FileChannel chan; public FileLock(String path) throws Exception { raf = new RandomAccessFile(path, "rw"); diff --git a/main/client/src/mill/main/client/lock/FileLocked.java b/main/client/src/mill/main/client/lock/FileLocked.java index 5fcba8b6c4d..ae31613278b 100644 --- a/main/client/src/mill/main/client/lock/FileLocked.java +++ b/main/client/src/mill/main/client/lock/FileLocked.java @@ -2,7 +2,7 @@ class FileLocked implements Locked { - protected java.nio.channels.FileLock lock; + final protected java.nio.channels.FileLock lock; public FileLocked(java.nio.channels.FileLock lock) { this.lock = lock; diff --git a/main/client/src/mill/main/client/lock/Locks.java b/main/client/src/mill/main/client/lock/Locks.java index 8fc5ad04270..22472592d07 100644 --- a/main/client/src/mill/main/client/lock/Locks.java +++ b/main/client/src/mill/main/client/lock/Locks.java @@ -2,26 +2,32 @@ import mill.main.client.ServerFiles; -public class Locks implements AutoCloseable { +final public class Locks implements AutoCloseable { - public Lock processLock; - public Lock serverLock; - public Lock clientLock; + final public Lock processLock; + final public Lock serverLock; + final public Lock clientLock; + + public Locks(Lock processLock, Lock serverLock, Lock clientLock){ + this.processLock = processLock; + this.serverLock = serverLock; + this.clientLock = clientLock; + } public static Locks files(String lockBase) throws Exception { - return new Locks(){{ - processLock = new FileLock(lockBase + "/" + ServerFiles.processLock); - serverLock = new FileLock(lockBase + "/" + ServerFiles.serverLock); - clientLock = new FileLock(lockBase + "/" + ServerFiles.clientLock); - }}; + return new Locks( + new FileLock(lockBase + "/" + ServerFiles.processLock), + new FileLock(lockBase + "/" + ServerFiles.serverLock), + new FileLock(lockBase + "/" + ServerFiles.clientLock) + ); } public static Locks memory() { - return new Locks(){{ - this.processLock = new MemoryLock(); - this.serverLock = new MemoryLock(); - this.clientLock = new MemoryLock(); - }}; + return new Locks( + new MemoryLock(), + new MemoryLock(), + new MemoryLock() + ); } @Override diff --git a/main/client/src/mill/main/client/lock/MemoryLock.java b/main/client/src/mill/main/client/lock/MemoryLock.java index bf55a5c216c..0e523c34898 100644 --- a/main/client/src/mill/main/client/lock/MemoryLock.java +++ b/main/client/src/mill/main/client/lock/MemoryLock.java @@ -4,7 +4,7 @@ class MemoryLock extends Lock { - private ReentrantLock innerLock = new ReentrantLock(); + final private ReentrantLock innerLock = new ReentrantLock(); public boolean probe() { return !innerLock.isLocked(); diff --git a/main/client/src/mill/main/client/lock/MemoryLocked.java b/main/client/src/mill/main/client/lock/MemoryLocked.java index 76cb91a09a3..37bdc3cb625 100644 --- a/main/client/src/mill/main/client/lock/MemoryLocked.java +++ b/main/client/src/mill/main/client/lock/MemoryLocked.java @@ -2,7 +2,7 @@ class MemoryLocked implements Locked { - protected java.util.concurrent.locks.Lock lock; + final protected java.util.concurrent.locks.Lock lock; public MemoryLocked(java.util.concurrent.locks.Lock lock) { this.lock = lock;