This commit is contained in:
Len
2022-10-19 19:22:56 +02:00
parent 07413c57bc
commit 83e5834c0f
11 changed files with 12 additions and 13 deletions
@@ -0,0 +1,31 @@
package com.alttd.datalock;
import org.jetbrains.annotations.ApiStatus;
public interface DataLockAPI {
static DataLockAPI get() {
return Provider.instance;
}
final class Provider {
private static DataLockAPI instance = null;
@ApiStatus.Internal
static void register(DataLockAPI instance) {
if (Provider.instance != null)
throw new UnsupportedOperationException("Cannot redefine singleton");
Provider.instance = instance;
}
}
void tryLock(String channel, String data);
void tryUnlock(String channel, String data);
void registerChannel(String channel);
boolean isActiveChannel(String channel);
}
@@ -0,0 +1,13 @@
package com.alttd.datalock;
enum RequestType {
TRY_LOCK("try-lock"),
TRY_UNLOCK("try-unlock"),
CHECK_LOCK("check-lock");
String subChannel;
RequestType(String subChannel) {
this.subChannel = subChannel;
}
}
@@ -0,0 +1,9 @@
package com.alttd.datalock;
public enum ResponseType {
TRY_LOCK_RESULT,
QUEUE_LOCK_FAILED,
TRY_UNLOCK_RESULT,
LOCKED_QUEUE_LOCK,
CHECK_LOCK_RESULT
}