diff options
Diffstat (limited to 'client')
-rw-r--r-- | client/src/mill/client/Lock.java | 13 | ||||
-rw-r--r-- | client/src/mill/client/Locked.java | 10 | ||||
-rw-r--r-- | client/src/mill/client/Locks.java | 22 | ||||
-rw-r--r-- | client/src/mill/client/Main.java (renamed from client/src/mill/client/Client.java) | 9 |
4 files changed, 31 insertions, 23 deletions
diff --git a/client/src/mill/client/Lock.java b/client/src/mill/client/Lock.java new file mode 100644 index 00000000..115529d3 --- /dev/null +++ b/client/src/mill/client/Lock.java @@ -0,0 +1,13 @@ +package mill.client; +public abstract class Lock{ + abstract public Locked lock() throws Exception; + abstract public Locked tryLock() throws Exception; + public void await() throws Exception{ + lock().release(); + } + + /** + * Returns `true` if the lock is *available for taking* + */ + abstract public boolean probe() throws Exception; +}
\ No newline at end of file diff --git a/client/src/mill/client/Locked.java b/client/src/mill/client/Locked.java new file mode 100644 index 00000000..6ba7dab5 --- /dev/null +++ b/client/src/mill/client/Locked.java @@ -0,0 +1,10 @@ +package mill.client; + +import java.io.RandomAccessFile; +import java.nio.channels.FileChannel; +import java.util.concurrent.locks.ReentrantLock; + + +public interface Locked{ + public void release() throws Exception; +}
\ No newline at end of file diff --git a/client/src/mill/client/Locks.java b/client/src/mill/client/Locks.java index 2cc86abf..3b397fce 100644 --- a/client/src/mill/client/Locks.java +++ b/client/src/mill/client/Locks.java @@ -4,27 +4,11 @@ import java.io.RandomAccessFile; import java.nio.channels.FileChannel; import java.util.concurrent.locks.ReentrantLock; - -abstract class Lock{ - abstract public Locked lock() throws Exception; - abstract public Locked tryLock() throws Exception; - public void await() throws Exception{ - lock().release(); - } - - /** - * Returns `true` if the lock is *available for taking* - */ - abstract public boolean probe() throws Exception; -} -interface Locked{ - void release() throws Exception; -} -class Locks{ +public class Locks{ public Lock processLock; public Lock serverLock; public Lock clientLock; - static Locks files(String lockBase) throws Exception{ + public static Locks files(String lockBase) throws Exception{ return new Locks(){{ processLock = new FileLock(lockBase + "/pid"); @@ -33,7 +17,7 @@ class Locks{ clientLock = new FileLock(lockBase + "/clientLock"); }}; } - static Locks memory(){ + public static Locks memory(){ return new Locks(){{ this.processLock = new MemoryLock(); this.serverLock = new MemoryLock(); diff --git a/client/src/mill/client/Client.java b/client/src/mill/client/Main.java index dd984f13..a26b653e 100644 --- a/client/src/mill/client/Client.java +++ b/client/src/mill/client/Main.java @@ -12,10 +12,10 @@ import java.util.Arrays; import java.util.Iterator; import java.util.Properties; -public class Client { +public class Main { static void initServer(String lockBase, boolean setJnaNoSys) throws IOException,URISyntaxException{ ArrayList<String> selfJars = new ArrayList<String>(); - ClassLoader current = Client.class.getClassLoader(); + ClassLoader current = Main.class.getClassLoader(); while(current != null){ if (current instanceof java.net.URLClassLoader) { URL[] urls = ((java.net.URLClassLoader) current).getURLs(); @@ -41,8 +41,9 @@ public class Client { } l.add("-cp"); l.add(String.join(File.pathSeparator, selfJars)); - l.add("mill.ServerMain"); + l.add("mill.main.ServerMain"); l.add(lockBase); + new java.lang.ProcessBuilder() .command(l) .redirectOutput(new java.io.File(lockBase + "/logs")) @@ -66,7 +67,7 @@ public class Client { lockFile.close(); channel.close(); } else { - int exitCode = Client.run( + int exitCode = Main.run( lockBase, new Runnable() { @Override |