Creates a new instance of an executable service.
+ Each service is registered with a NamespacedKey,
+ to allow for easy identification within the associated ServicePool.
+
+
Parameters:
+
parentPool - The ServicePool which this service is executing on.
+
service_name - A namespaced key which can be used to identify the service.
Creates a new instance of an executable service.
+ The timings are measured in ticks (20 ticks per second).
+ You do not need to explicitly define a delay.
+ Each service is registered with a NamespacedKey,
+ to allow for easy identification within the associated ServicePool.
+
+
Parameters:
+
parentPool - The ServicePool which this service is executing on.
+
service_name - A namespaced key which can be used to identify the service.
+
delay - A specified amount of time (in ticks) to wait before the service runs.
Creates a new instance of an executable service.
+ The timings are measured in ticks (20 ticks per second).
+ You do not need to explicitly define a delay or a period,
+ however if you have flagged repeating as true, and the period is null,
+ then the period will automatically be set to 20 minutes.
+ Each service is registered with a NamespacedKey,
+ to allow for easy identification within the associated ServicePool.
+
+
Parameters:
+
parentPool - The ServicePool which this service is executing on.
+
service_name - A namespaced key which can be used to identify the service.
+
delay - A specified amount of time (in ticks) to wait before the service runs.
+
period - How long the service should wait between service executions (in ticks).
+
repeating - If the service should be scheduled for repeated executions or not.
Creates a new instance of the Service Manager class.
+ This class acts as a Service Pool factory, and can be used to create
+ both single and multithreaded Service Pools, empty service pools, as well as
+ retrieve existing Service Pools. It also provides methods for you to add and remove
+ IServices from the {ServicePool} parameter.
service_name - The name of the service to queue. This should be a service that is located within this service pool.
+ If you name a service that is stored within another service pool,
+ this method will throw an error.
+
Returns:
+
A Mono object which contains a Disposable element which can be used to destroy the registered service.
A Flux object which contains a collection of Disposable elements,
+ which can be used to destroy the registered services using stopServices(Flux<Disposable>).
The Scheduler which hosts the threads for the service pool.
+
diff --git a/docs/io/github/simplex/simplexss/package-summary.html b/docs/io/github/simplex/simplexss/package-summary.html
index b9a1422..b267119 100644
--- a/docs/io/github/simplex/simplexss/package-summary.html
+++ b/docs/io/github/simplex/simplexss/package-summary.html
@@ -1,11 +1,11 @@
-
+
io.github.simplex.simplexss
-
+
diff --git a/docs/io/github/simplex/simplexss/package-tree.html b/docs/io/github/simplex/simplexss/package-tree.html
index df057ac..1002240 100644
--- a/docs/io/github/simplex/simplexss/package-tree.html
+++ b/docs/io/github/simplex/simplexss/package-tree.html
@@ -1,11 +1,11 @@
-
+
io.github.simplex.simplexss Class Hierarchy
-
+
diff --git a/docs/member-search-index.js b/docs/member-search-index.js
index 99de2fd..1242ee8 100644
--- a/docs/member-search-index.js
+++ b/docs/member-search-index.js
@@ -1 +1 @@
-memberSearchIndex = [{"p":"io.github.simplex.simplexss","c":"ServicePool","l":"addService(IService)","u":"addService(io.github.simplex.api.IService)"},{"p":"io.github.simplex.simplexss","c":"ServiceManager","l":"addToExistingPool(ServicePool, IService...)","u":"addToExistingPool(io.github.simplex.simplexss.ServicePool,io.github.simplex.api.IService...)"},{"p":"io.github.simplex.simplexss","c":"ServicePool","l":"associatedServices"},{"p":"io.github.simplex.api","c":"ExecutableService","l":"cancel()"},{"p":"io.github.simplex.api","c":"ExecutableService","l":"cancelled"},{"p":"io.github.simplex.api","c":"Context","l":"contextCollection()"},{"p":"io.github.simplex.simplexss","c":"ServiceManager","l":"createServicePool(NamespacedKey, IService...)","u":"createServicePool(org.bukkit.NamespacedKey,io.github.simplex.api.IService...)"},{"p":"io.github.simplex.simplexss","c":"ServicePool","l":"DEFAULT"},{"p":"io.github.simplex.api","c":"ExecutableService","l":"delay"},{"p":"io.github.simplex.impl","c":"Main","l":"disposables"},{"p":"io.github.simplex.simplexss","c":"ServiceManager","l":"emptyServicePool(NamespacedKey, boolean)","u":"emptyServicePool(org.bukkit.NamespacedKey,boolean)"},{"p":"io.github.simplex.api","c":"ExecutableService","l":"ExecutableService(NamespacedKey, Long, Long, Boolean, Boolean)","u":"%3Cinit%3E(org.bukkit.NamespacedKey,java.lang.Long,java.lang.Long,java.lang.Boolean,java.lang.Boolean)"},{"p":"io.github.simplex.api","c":"Context","l":"fluxFromCollection()"},{"p":"io.github.simplex.api","c":"ISchedule","l":"forceStart(IService)","u":"forceStart(io.github.simplex.api.IService)"},{"p":"io.github.simplex.simplexss","c":"SchedulingSystem","l":"forceStart(IService)","u":"forceStart(io.github.simplex.api.IService)"},{"p":"io.github.simplex.api","c":"ISchedule","l":"forceStop(IService)","u":"forceStop(io.github.simplex.api.IService)"},{"p":"io.github.simplex.simplexss","c":"SchedulingSystem","l":"forceStop(IService)","u":"forceStop(io.github.simplex.api.IService)"},{"p":"io.github.simplex.simplexss","c":"ServiceManager","l":"getAssociatedServicePool(IService)","u":"getAssociatedServicePool(io.github.simplex.api.IService)"},{"p":"io.github.simplex.simplexss","c":"ServicePool","l":"getAssociatedServices()"},{"p":"io.github.simplex.api","c":"Context","l":"getContext()"},{"p":"io.github.simplex.api","c":"IService","l":"getDefaultNamespacedKey()"},{"p":"io.github.simplex.simplexss","c":"ServicePool","l":"getDefaultNamespacedKey()"},{"p":"io.github.simplex.api","c":"ExecutableService","l":"getDelay()"},{"p":"io.github.simplex.api","c":"IService","l":"getDelay()"},{"p":"io.github.simplex.simplexss","c":"SchedulingSystem","l":"getMainSchedulerThread()"},{"p":"io.github.simplex.api","c":"ExecutableService","l":"getNamespacedKey()"},{"p":"io.github.simplex.api","c":"IService","l":"getNamespacedKey()"},{"p":"io.github.simplex.api","c":"IService","l":"getParentPool()"},{"p":"io.github.simplex.impl","c":"ServiceImpl","l":"getParentPool()"},{"p":"io.github.simplex.api","c":"ExecutableService","l":"getPeriod()"},{"p":"io.github.simplex.api","c":"IService","l":"getPeriod()"},{"p":"io.github.simplex.api","c":"IService","l":"getPlugin()"},{"p":"io.github.simplex.impl","c":"ServiceImpl","l":"getPlugin()"},{"p":"io.github.simplex.simplexss","c":"SchedulingSystem","l":"getProvidingPlugin()"},{"p":"io.github.simplex.simplexss","c":"SchedulingSystem","l":"getRepeatingPools()"},{"p":"io.github.simplex.impl","c":"Main","l":"getScheduler()"},{"p":"io.github.simplex.simplexss","c":"ServicePool","l":"getScheduler()"},{"p":"io.github.simplex.simplexss","c":"ServicePool","l":"getService(NamespacedKey)","u":"getService(org.bukkit.NamespacedKey)"},{"p":"io.github.simplex.api","c":"ISchedule","l":"getServiceManager()"},{"p":"io.github.simplex.simplexss","c":"SchedulingSystem","l":"getServiceManager()"},{"p":"io.github.simplex.simplexss","c":"ServiceManager","l":"getServicePools()"},{"p":"io.github.simplex.api","c":"InvalidServiceException","l":"InvalidServiceException(IService)","u":"%3Cinit%3E(io.github.simplex.api.IService)"},{"p":"io.github.simplex.api","c":"InvalidServiceException","l":"InvalidServiceException(Throwable)","u":"%3Cinit%3E(java.lang.Throwable)"},{"p":"io.github.simplex.api","c":"InvalidServicePoolException","l":"InvalidServicePoolException()","u":"%3Cinit%3E()"},{"p":"io.github.simplex.api","c":"InvalidServicePoolException","l":"InvalidServicePoolException(Throwable)","u":"%3Cinit%3E(java.lang.Throwable)"},{"p":"io.github.simplex.api","c":"ExecutableService","l":"isCancelled()"},{"p":"io.github.simplex.api","c":"ExecutableService","l":"isPeriodic()"},{"p":"io.github.simplex.api","c":"IService","l":"isPeriodic()"},{"p":"io.github.simplex.simplexss","c":"ServicePool","l":"isValidService(IService)","u":"isValidService(io.github.simplex.api.IService)"},{"p":"io.github.simplex.simplexss","c":"ServiceManager","l":"locateServiceWithinPools(IService)","u":"locateServiceWithinPools(io.github.simplex.api.IService)"},{"p":"io.github.simplex.impl","c":"Main","l":"Main()","u":"%3Cinit%3E()"},{"p":"io.github.simplex.simplexss","c":"SchedulingSystem","l":"mainScheduler"},{"p":"io.github.simplex.api","c":"ExecutableService","l":"mayInterruptWhenRunning"},{"p":"io.github.simplex.simplexss","c":"ServiceManager","l":"multithreadedServicePool(NamespacedKey, IService...)","u":"multithreadedServicePool(org.bukkit.NamespacedKey,io.github.simplex.api.IService...)"},{"p":"io.github.simplex.simplexss","c":"ServicePool","l":"name"},{"p":"io.github.simplex.impl","c":"Main","l":"onDisable()"},{"p":"io.github.simplex.impl","c":"Main","l":"onEnable()"},{"p":"io.github.simplex.api","c":"ExecutableService","l":"period"},{"p":"io.github.simplex.impl","c":"ServiceImpl","l":"plugin"},{"p":"io.github.simplex.simplexss","c":"SchedulingSystem","l":"plugin"},{"p":"io.github.simplex.simplexss","c":"SchedulingSystem","l":"queue(IService)","u":"queue(io.github.simplex.api.IService)"},{"p":"io.github.simplex.api","c":"ISchedule","l":"queue(IService)","u":"queue(io.github.simplex.api.IService)"},{"p":"io.github.simplex.simplexss","c":"ServicePool","l":"recycle()"},{"p":"io.github.simplex.simplexss","c":"ServicePool","l":"removeService(IService)","u":"removeService(io.github.simplex.api.IService)"},{"p":"io.github.simplex.api","c":"ExecutableService","l":"repeating"},{"p":"io.github.simplex.simplexss","c":"SchedulingSystem","l":"repeatingPools"},{"p":"io.github.simplex.api","c":"IService","l":"run()"},{"p":"io.github.simplex.api","c":"ISchedule","l":"runOnce(IService)","u":"runOnce(io.github.simplex.api.IService)"},{"p":"io.github.simplex.simplexss","c":"SchedulingSystem","l":"runOnce(IService)","u":"runOnce(io.github.simplex.api.IService)"},{"p":"io.github.simplex.impl","c":"Main","l":"scheduler"},{"p":"io.github.simplex.simplexss","c":"ServicePool","l":"scheduler"},{"p":"io.github.simplex.simplexss","c":"SchedulingSystem","l":"SchedulingSystem(ServiceManager, T)","u":"%3Cinit%3E(io.github.simplex.simplexss.ServiceManager,T)"},{"p":"io.github.simplex.api","c":"ExecutableService","l":"service_name"},{"p":"io.github.simplex.impl","c":"ServiceImpl","l":"ServiceImpl(Main)","u":"%3Cinit%3E(io.github.simplex.impl.Main)"},{"p":"io.github.simplex.simplexss","c":"SchedulingSystem","l":"serviceManager"},{"p":"io.github.simplex.simplexss","c":"ServiceManager","l":"ServiceManager()","u":"%3Cinit%3E()"},{"p":"io.github.simplex.simplexss","c":"ServicePool","l":"ServicePool(NamespacedKey, boolean)","u":"%3Cinit%3E(org.bukkit.NamespacedKey,boolean)"},{"p":"io.github.simplex.simplexss","c":"ServiceManager","l":"servicePools"},{"p":"io.github.simplex.api","c":"ExecutableService","l":"setCancelled(boolean)"},{"p":"io.github.simplex.api","c":"Context","l":"setContext(S)"},{"p":"io.github.simplex.api","c":"IService","l":"start()"},{"p":"io.github.simplex.impl","c":"ServiceImpl","l":"start()"},{"p":"io.github.simplex.simplexss","c":"ServicePool","l":"startService(NamespacedKey)","u":"startService(org.bukkit.NamespacedKey)"},{"p":"io.github.simplex.simplexss","c":"ServicePool","l":"startServices()"},{"p":"io.github.simplex.api","c":"IService","l":"stop()"},{"p":"io.github.simplex.impl","c":"ServiceImpl","l":"stop()"},{"p":"io.github.simplex.simplexss","c":"ServicePool","l":"stopService(NamespacedKey)","u":"stopService(org.bukkit.NamespacedKey)"},{"p":"io.github.simplex.simplexss","c":"ServicePool","l":"stopServices(Flux)","u":"stopServices(reactor.core.publisher.Flux)"},{"p":"io.github.simplex.api","c":"InvalidServicePoolException","l":"supplyException()"},{"p":"io.github.simplex.api","c":"InvalidServiceException","l":"supplyException(IService)","u":"supplyException(io.github.simplex.api.IService)"},{"p":"io.github.simplex.simplexss","c":"ServiceManager","l":"takeFromExistingPool(ServicePool, IService...)","u":"takeFromExistingPool(io.github.simplex.simplexss.ServicePool,io.github.simplex.api.IService...)"}];updateSearchResults();
\ No newline at end of file
+memberSearchIndex = [{"p":"io.github.simplex.simplexss","c":"ServicePool","l":"addService(IService)","u":"addService(io.github.simplex.api.IService)"},{"p":"io.github.simplex.simplexss","c":"ServiceManager","l":"addToExistingPool(ServicePool, IService...)","u":"addToExistingPool(io.github.simplex.simplexss.ServicePool,io.github.simplex.api.IService...)"},{"p":"io.github.simplex.simplexss","c":"ServicePool","l":"associatedServices"},{"p":"io.github.simplex.api","c":"ExecutableService","l":"cancel()"},{"p":"io.github.simplex.api","c":"ExecutableService","l":"cancelled"},{"p":"io.github.simplex.api","c":"Context","l":"contextCollection()"},{"p":"io.github.simplex.simplexss","c":"ServiceManager","l":"createServicePool(NamespacedKey, IService...)","u":"createServicePool(org.bukkit.NamespacedKey,io.github.simplex.api.IService...)"},{"p":"io.github.simplex.simplexss","c":"ServicePool","l":"DEFAULT"},{"p":"io.github.simplex.api","c":"ExecutableService","l":"delay"},{"p":"io.github.simplex.impl","c":"Main","l":"disposables"},{"p":"io.github.simplex.simplexss","c":"ServiceManager","l":"emptyServicePool(NamespacedKey, boolean)","u":"emptyServicePool(org.bukkit.NamespacedKey,boolean)"},{"p":"io.github.simplex.api","c":"ExecutableService","l":"ExecutableService(NamespacedKey)","u":"%3Cinit%3E(org.bukkit.NamespacedKey)"},{"p":"io.github.simplex.api","c":"ExecutableService","l":"ExecutableService(ServicePool, NamespacedKey)","u":"%3Cinit%3E(io.github.simplex.simplexss.ServicePool,org.bukkit.NamespacedKey)"},{"p":"io.github.simplex.api","c":"ExecutableService","l":"ExecutableService(ServicePool, NamespacedKey, Long)","u":"%3Cinit%3E(io.github.simplex.simplexss.ServicePool,org.bukkit.NamespacedKey,java.lang.Long)"},{"p":"io.github.simplex.api","c":"ExecutableService","l":"ExecutableService(ServicePool, NamespacedKey, Long, Long, Boolean)","u":"%3Cinit%3E(io.github.simplex.simplexss.ServicePool,org.bukkit.NamespacedKey,java.lang.Long,java.lang.Long,java.lang.Boolean)"},{"p":"io.github.simplex.api","c":"ExecutableService","l":"ExecutableService(ServicePool, NamespacedKey, Long, Long, Boolean, Boolean)","u":"%3Cinit%3E(io.github.simplex.simplexss.ServicePool,org.bukkit.NamespacedKey,java.lang.Long,java.lang.Long,java.lang.Boolean,java.lang.Boolean)"},{"p":"io.github.simplex.api","c":"Context","l":"fluxFromCollection()"},{"p":"io.github.simplex.api","c":"ISchedule","l":"forceStart(IService)","u":"forceStart(io.github.simplex.api.IService)"},{"p":"io.github.simplex.simplexss","c":"SchedulingSystem","l":"forceStart(IService)","u":"forceStart(io.github.simplex.api.IService)"},{"p":"io.github.simplex.api","c":"ISchedule","l":"forceStop(IService)","u":"forceStop(io.github.simplex.api.IService)"},{"p":"io.github.simplex.simplexss","c":"SchedulingSystem","l":"forceStop(IService)","u":"forceStop(io.github.simplex.api.IService)"},{"p":"io.github.simplex.simplexss","c":"ServiceManager","l":"getAssociatedServicePool(IService)","u":"getAssociatedServicePool(io.github.simplex.api.IService)"},{"p":"io.github.simplex.simplexss","c":"ServicePool","l":"getAssociatedServices()"},{"p":"io.github.simplex.api","c":"Context","l":"getContext()"},{"p":"io.github.simplex.api","c":"IService","l":"getDefaultNamespacedKey()"},{"p":"io.github.simplex.simplexss","c":"ServicePool","l":"getDefaultNamespacedKey()"},{"p":"io.github.simplex.api","c":"ExecutableService","l":"getDelay()"},{"p":"io.github.simplex.api","c":"IService","l":"getDelay()"},{"p":"io.github.simplex.simplexss","c":"SchedulingSystem","l":"getMainSchedulerThread()"},{"p":"io.github.simplex.api","c":"ExecutableService","l":"getNamespacedKey()"},{"p":"io.github.simplex.api","c":"IService","l":"getNamespacedKey()"},{"p":"io.github.simplex.api","c":"ExecutableService","l":"getParentPool()"},{"p":"io.github.simplex.api","c":"IService","l":"getParentPool()"},{"p":"io.github.simplex.impl","c":"ServiceImpl","l":"getParentPool()"},{"p":"io.github.simplex.api","c":"ExecutableService","l":"getPeriod()"},{"p":"io.github.simplex.api","c":"IService","l":"getPeriod()"},{"p":"io.github.simplex.api","c":"IService","l":"getPlugin()"},{"p":"io.github.simplex.impl","c":"ServiceImpl","l":"getPlugin()"},{"p":"io.github.simplex.simplexss","c":"SchedulingSystem","l":"getProvidingPlugin()"},{"p":"io.github.simplex.simplexss","c":"SchedulingSystem","l":"getRepeatingPools()"},{"p":"io.github.simplex.impl","c":"Main","l":"getScheduler()"},{"p":"io.github.simplex.simplexss","c":"ServicePool","l":"getScheduler()"},{"p":"io.github.simplex.simplexss","c":"ServicePool","l":"getService(NamespacedKey)","u":"getService(org.bukkit.NamespacedKey)"},{"p":"io.github.simplex.api","c":"ISchedule","l":"getServiceManager()"},{"p":"io.github.simplex.simplexss","c":"SchedulingSystem","l":"getServiceManager()"},{"p":"io.github.simplex.simplexss","c":"ServiceManager","l":"getServicePools()"},{"p":"io.github.simplex.api","c":"InvalidServiceException","l":"InvalidServiceException(IService)","u":"%3Cinit%3E(io.github.simplex.api.IService)"},{"p":"io.github.simplex.api","c":"InvalidServiceException","l":"InvalidServiceException(Throwable)","u":"%3Cinit%3E(java.lang.Throwable)"},{"p":"io.github.simplex.api","c":"InvalidServicePoolException","l":"InvalidServicePoolException()","u":"%3Cinit%3E()"},{"p":"io.github.simplex.api","c":"InvalidServicePoolException","l":"InvalidServicePoolException(Throwable)","u":"%3Cinit%3E(java.lang.Throwable)"},{"p":"io.github.simplex.api","c":"ExecutableService","l":"isCancelled()"},{"p":"io.github.simplex.api","c":"ExecutableService","l":"isPeriodic()"},{"p":"io.github.simplex.api","c":"IService","l":"isPeriodic()"},{"p":"io.github.simplex.simplexss","c":"ServicePool","l":"isValidService(IService)","u":"isValidService(io.github.simplex.api.IService)"},{"p":"io.github.simplex.simplexss","c":"ServiceManager","l":"locateServiceWithinPools(IService)","u":"locateServiceWithinPools(io.github.simplex.api.IService)"},{"p":"io.github.simplex.impl","c":"Main","l":"Main()","u":"%3Cinit%3E()"},{"p":"io.github.simplex.simplexss","c":"SchedulingSystem","l":"mainScheduler"},{"p":"io.github.simplex.api","c":"ExecutableService","l":"mayInterruptWhenRunning"},{"p":"io.github.simplex.simplexss","c":"ServiceManager","l":"multithreadedServicePool(NamespacedKey, IService...)","u":"multithreadedServicePool(org.bukkit.NamespacedKey,io.github.simplex.api.IService...)"},{"p":"io.github.simplex.simplexss","c":"ServicePool","l":"name"},{"p":"io.github.simplex.api","c":"IService","l":"newNamespacedKey(String, String)","u":"newNamespacedKey(java.lang.String,java.lang.String)"},{"p":"io.github.simplex.impl","c":"Main","l":"onDisable()"},{"p":"io.github.simplex.impl","c":"Main","l":"onEnable()"},{"p":"io.github.simplex.api","c":"ExecutableService","l":"parentPool"},{"p":"io.github.simplex.api","c":"ExecutableService","l":"period"},{"p":"io.github.simplex.impl","c":"ServiceImpl","l":"plugin"},{"p":"io.github.simplex.simplexss","c":"SchedulingSystem","l":"plugin"},{"p":"io.github.simplex.impl","c":"Main","l":"pool"},{"p":"io.github.simplex.simplexss","c":"SchedulingSystem","l":"queue(IService)","u":"queue(io.github.simplex.api.IService)"},{"p":"io.github.simplex.api","c":"ISchedule","l":"queue(IService)","u":"queue(io.github.simplex.api.IService)"},{"p":"io.github.simplex.simplexss","c":"ServicePool","l":"queueService(NamespacedKey)","u":"queueService(org.bukkit.NamespacedKey)"},{"p":"io.github.simplex.simplexss","c":"ServicePool","l":"recycle()"},{"p":"io.github.simplex.simplexss","c":"ServicePool","l":"removeService(IService)","u":"removeService(io.github.simplex.api.IService)"},{"p":"io.github.simplex.api","c":"ExecutableService","l":"repeating"},{"p":"io.github.simplex.simplexss","c":"SchedulingSystem","l":"repeatingPools"},{"p":"io.github.simplex.api","c":"IService","l":"run()"},{"p":"io.github.simplex.api","c":"ISchedule","l":"runOnce(IService)","u":"runOnce(io.github.simplex.api.IService)"},{"p":"io.github.simplex.simplexss","c":"SchedulingSystem","l":"runOnce(IService)","u":"runOnce(io.github.simplex.api.IService)"},{"p":"io.github.simplex.impl","c":"Main","l":"scheduler"},{"p":"io.github.simplex.simplexss","c":"ServicePool","l":"scheduler"},{"p":"io.github.simplex.simplexss","c":"SchedulingSystem","l":"SchedulingSystem(ServiceManager, T)","u":"%3Cinit%3E(io.github.simplex.simplexss.ServiceManager,T)"},{"p":"io.github.simplex.api","c":"ExecutableService","l":"service_name"},{"p":"io.github.simplex.impl","c":"ServiceImpl","l":"ServiceImpl(Main)","u":"%3Cinit%3E(io.github.simplex.impl.Main)"},{"p":"io.github.simplex.simplexss","c":"SchedulingSystem","l":"serviceManager"},{"p":"io.github.simplex.simplexss","c":"ServiceManager","l":"ServiceManager()","u":"%3Cinit%3E()"},{"p":"io.github.simplex.simplexss","c":"ServicePool","l":"ServicePool(NamespacedKey, boolean)","u":"%3Cinit%3E(org.bukkit.NamespacedKey,boolean)"},{"p":"io.github.simplex.simplexss","c":"ServiceManager","l":"servicePools"},{"p":"io.github.simplex.api","c":"ExecutableService","l":"setCancelled(boolean)"},{"p":"io.github.simplex.api","c":"Context","l":"setContext(S)"},{"p":"io.github.simplex.api","c":"IService","l":"start()"},{"p":"io.github.simplex.impl","c":"ServiceImpl","l":"start()"},{"p":"io.github.simplex.simplexss","c":"ServicePool","l":"startServices()"},{"p":"io.github.simplex.api","c":"IService","l":"stop()"},{"p":"io.github.simplex.impl","c":"ServiceImpl","l":"stop()"},{"p":"io.github.simplex.simplexss","c":"ServicePool","l":"stopService(NamespacedKey, Mono)","u":"stopService(org.bukkit.NamespacedKey,reactor.core.publisher.Mono)"},{"p":"io.github.simplex.simplexss","c":"ServicePool","l":"stopServices(Flux)","u":"stopServices(reactor.core.publisher.Flux)"},{"p":"io.github.simplex.api","c":"InvalidServicePoolException","l":"supplyException()"},{"p":"io.github.simplex.api","c":"InvalidServiceException","l":"supplyException(IService)","u":"supplyException(io.github.simplex.api.IService)"},{"p":"io.github.simplex.simplexss","c":"ServiceManager","l":"takeFromExistingPool(ServicePool, IService...)","u":"takeFromExistingPool(io.github.simplex.simplexss.ServicePool,io.github.simplex.api.IService...)"}];updateSearchResults();
\ No newline at end of file
diff --git a/docs/overview-summary.html b/docs/overview-summary.html
index 382fda0..244c0ea 100644
--- a/docs/overview-summary.html
+++ b/docs/overview-summary.html
@@ -1,11 +1,11 @@
-
+
Generated Documentation (Untitled)
-
+
diff --git a/docs/overview-tree.html b/docs/overview-tree.html
index 83a3b4d..4c1e915 100644
--- a/docs/overview-tree.html
+++ b/docs/overview-tree.html
@@ -1,11 +1,11 @@
-
+
Class Hierarchy
-
+
diff --git a/docs/serialized-form.html b/docs/serialized-form.html
index 2de287a..2ac593d 100644
--- a/docs/serialized-form.html
+++ b/docs/serialized-form.html
@@ -1,11 +1,11 @@
-
+
Serialized Form
-
+
diff --git a/src/main/java/io/github/simplex/api/ExecutableService.java b/src/main/java/io/github/simplex/api/ExecutableService.java
index b3b3c8c..8b30ea2 100644
--- a/src/main/java/io/github/simplex/api/ExecutableService.java
+++ b/src/main/java/io/github/simplex/api/ExecutableService.java
@@ -17,6 +17,48 @@ public abstract class ExecutableService implements IService {
private final boolean mayInterruptWhenRunning;
private boolean cancelled = false;
+ private ServicePool parentPool;
+
+ /**
+ * Creates a new instance of an executable service.
+ * Each service is registered with a {@link NamespacedKey},
+ * to allow for easy identification within the associated {@link ServicePool}.
+ *
+ * @param service_name A namespaced key which can be used to identify the service.
+ */
+ public ExecutableService(@NotNull NamespacedKey service_name) {
+ this((new ServicePool(IService.newNamespacedKey("", ""), false)), service_name, 0L, 0L, false, false);
+ }
+
+ /**
+ * Creates a new instance of an executable service.
+ * Each service is registered with a {@link NamespacedKey},
+ * to allow for easy identification within the associated {@link ServicePool}.
+ *
+ * @param parentPool The {@link ServicePool} which this service is executing on.
+ * @param service_name A namespaced key which can be used to identify the service.
+ */
+ public ExecutableService(@Nullable ServicePool parentPool, @NotNull NamespacedKey service_name) {
+ this(parentPool, service_name, 0L, 0L, false, false);
+ }
+
+ /**
+ * Creates a new instance of an executable service.
+ * The timings are measured in ticks (20 ticks per second).
+ * You do not need to explicitly define a delay.
+ * Each service is registered with a {@link NamespacedKey},
+ * to allow for easy identification within the associated {@link ServicePool}.
+ *
+ * @param parentPool The {@link ServicePool} which this service is executing on.
+ * @param service_name A namespaced key which can be used to identify the service.
+ * @param delay A specified amount of time (in ticks) to wait before the service runs.
+ */
+ public ExecutableService(
+ @Nullable ServicePool parentPool,
+ @NotNull NamespacedKey service_name,
+ @Nullable Long delay) {
+ this(parentPool, service_name, delay, 0L, false, false);
+ }
/**
* Creates a new instance of an executable service.
@@ -27,6 +69,31 @@ public abstract class ExecutableService implements IService {
* Each service is registered with a {@link NamespacedKey},
* to allow for easy identification within the associated {@link ServicePool}.
*
+ * @param parentPool The {@link ServicePool} which this service is executing on.
+ * @param service_name A namespaced key which can be used to identify the service.
+ * @param delay A specified amount of time (in ticks) to wait before the service runs.
+ * @param period How long the service should wait between service executions (in ticks).
+ * @param repeating If the service should be scheduled for repeated executions or not.
+ */
+ public ExecutableService(
+ @Nullable ServicePool parentPool,
+ @NotNull NamespacedKey service_name,
+ @NotNull Long delay,
+ @NotNull Long period,
+ @NotNull Boolean repeating) {
+ this(parentPool, service_name, delay, period, repeating, false);
+ }
+
+ /**
+ * Creates a new instance of an executable service.
+ * The timings are measured in ticks (20 ticks per second).
+ * You do not need to explicitly define a delay or a period,
+ * however if you have flagged {@link #repeating} as true, and the period is null,
+ * then the period will automatically be set to 20 minutes.
+ * Each service is registered with a {@link NamespacedKey},
+ * to allow for easy identification within the associated {@link ServicePool}.
+ *
+ * @param parentPool The {@link ServicePool} which this service is executing on.
* @param service_name A namespaced key which can be used to identify the service.
* @param delay A specified amount of time (in ticks) to wait before the service runs.
* @param period How long the service should wait between service executions (in ticks).
@@ -34,6 +101,7 @@ public abstract class ExecutableService implements IService {
* @param mayInterruptWhenRunning If the service can be cancelled during execution.
*/
public ExecutableService(
+ @Nullable ServicePool parentPool,
@NotNull NamespacedKey service_name,
@Nullable Long delay,
@Nullable Long period,
@@ -44,6 +112,7 @@ public abstract class ExecutableService implements IService {
this.delay = Objects.requireNonNullElse(delay, 0L);
this.period = Objects.requireNonNullElse(period, (20L * 60L) * 20L);
this.mayInterruptWhenRunning = mayInterruptWhenRunning;
+ this.parentPool = parentPool;
}
@Override
@@ -99,4 +168,9 @@ public abstract class ExecutableService implements IService {
}
return Mono.empty();
}
+
+ @Override
+ public Mono getParentPool() {
+ return Mono.just(parentPool);
+ }
}
diff --git a/src/main/java/io/github/simplex/api/IService.java b/src/main/java/io/github/simplex/api/IService.java
index aad787b..97af0a1 100644
--- a/src/main/java/io/github/simplex/api/IService.java
+++ b/src/main/java/io/github/simplex/api/IService.java
@@ -68,4 +68,16 @@ public interface IService extends Runnable {
.orElseThrow(InvalidServicePoolException.supplyException()))
.subscribe();
}
+
+ /**
+ * This is an easy static call for creating a new namespaced key for services and service pools.
+ *
+ * @param space The namespace of the service.
+ * @param key The key name of the service.
+ * @return A NamespacedKey object representing the service.
+ */
+ @Contract("_, _ -> new")
+ static @NotNull NamespacedKey newNamespacedKey(String space, String key) {
+ return new NamespacedKey(space, key);
+ }
}
diff --git a/src/main/java/io/github/simplex/api/InvalidServiceException.java b/src/main/java/io/github/simplex/api/InvalidServiceException.java
index 363c126..157dcc8 100644
--- a/src/main/java/io/github/simplex/api/InvalidServiceException.java
+++ b/src/main/java/io/github/simplex/api/InvalidServiceException.java
@@ -4,7 +4,7 @@ import java.util.function.Supplier;
public class InvalidServiceException extends RuntimeException {
public InvalidServiceException(IService service) {
- super("The service " + service.getNamespacedKey().getKey() + " has encountered an exception.");
+ super("The service " + service.getNamespacedKey().getKey() + " is not present within any service pool.");
}
public InvalidServiceException(Throwable th) {
diff --git a/src/main/java/io/github/simplex/impl/Main.java b/src/main/java/io/github/simplex/impl/Main.java
index 402e391..dc8a4c4 100644
--- a/src/main/java/io/github/simplex/impl/Main.java
+++ b/src/main/java/io/github/simplex/impl/Main.java
@@ -1,7 +1,9 @@
package io.github.simplex.impl;
+import io.github.simplex.api.IService;
import io.github.simplex.simplexss.SchedulingSystem;
import io.github.simplex.simplexss.ServiceManager;
+import io.github.simplex.simplexss.ServicePool;
import org.bukkit.plugin.java.JavaPlugin;
import reactor.core.Disposable;
import reactor.core.publisher.Flux;
@@ -9,6 +11,7 @@ import reactor.core.publisher.Flux;
import java.util.Objects;
public class Main extends JavaPlugin {
+ public ServicePool pool = new ServicePool(IService.newNamespacedKey("pool", "one"), true);
private SchedulingSystem scheduler;
private Flux disposables;
@@ -16,10 +19,8 @@ public class Main extends JavaPlugin {
public void onEnable() {
ServiceManager serviceManager = new ServiceManager();
this.scheduler = new SchedulingSystem<>(serviceManager, this);
- scheduler.getServiceManager().subscribe(manager -> manager.getServicePools()
- .doOnEach(signal -> disposables = Objects.requireNonNull(signal.get()).startServices())
- .subscribeOn(scheduler.getMainSchedulerThread(), false)
- .subscribe());
+ IService service = new ServiceImpl(this);
+ service.getParentPool().subscribe(element -> disposables = element.startServices());
}
@Override
diff --git a/src/main/java/io/github/simplex/impl/ServiceImpl.java b/src/main/java/io/github/simplex/impl/ServiceImpl.java
index 0f60181..a4a597f 100644
--- a/src/main/java/io/github/simplex/impl/ServiceImpl.java
+++ b/src/main/java/io/github/simplex/impl/ServiceImpl.java
@@ -10,7 +10,7 @@ public class ServiceImpl extends ExecutableService {
private final Main plugin;
public ServiceImpl(Main plugin) {
- super(IService.getDefaultNamespacedKey(), 20L, 20L * 60L * 10L, true, true);
+ super(plugin.pool, IService.getDefaultNamespacedKey(), 0L, 20 * 60 * 20L, true, false);
this.plugin = plugin;
}
diff --git a/src/main/java/io/github/simplex/simplexss/SchedulingSystem.java b/src/main/java/io/github/simplex/simplexss/SchedulingSystem.java
index a9daeef..6ce84d6 100644
--- a/src/main/java/io/github/simplex/simplexss/SchedulingSystem.java
+++ b/src/main/java/io/github/simplex/simplexss/SchedulingSystem.java
@@ -19,6 +19,12 @@ public final class SchedulingSystem implements ISchedule {
private final Set repeatingPools;
private final Scheduler mainScheduler;
+ /**
+ * Creates a new instance of the scheduling system. This is used to manage the scheduling of services.
+ *
+ * @param serviceManager The service manager to use for this scheduling system.
+ * @param plugin The plugin to use for this scheduling system. This should be an instance of your plugin.
+ */
public SchedulingSystem(@NotNull ServiceManager serviceManager, T plugin) {
this.serviceManager = serviceManager;
this.plugin = plugin;
@@ -53,8 +59,7 @@ public final class SchedulingSystem implements ISchedule {
@Override
public @NotNull Mono runOnce(IService service) {
return Mono.just(service).doOnNext(s -> {
- s.start().subscribe();
- s.stop().subscribe();
+ s.start().then(s.stop()).subscribe();
}).then();
}
diff --git a/src/main/java/io/github/simplex/simplexss/ServiceManager.java b/src/main/java/io/github/simplex/simplexss/ServiceManager.java
index 89e466d..bff0c5b 100644
--- a/src/main/java/io/github/simplex/simplexss/ServiceManager.java
+++ b/src/main/java/io/github/simplex/simplexss/ServiceManager.java
@@ -14,6 +14,13 @@ import java.util.Set;
public final class ServiceManager {
private final Set servicePools;
+ /**
+ * Creates a new instance of the Service Manager class.
+ * This class acts as a Service Pool factory, and can be used to create
+ * both single and multithreaded Service Pools, empty service pools, as well as
+ * retrieve existing Service Pools. It also provides methods for you to add and remove
+ * {@link IService}s from the {ServicePool} parameter.
+ */
public ServiceManager() {
servicePools = new HashSet<>();
}
diff --git a/src/main/java/io/github/simplex/simplexss/ServicePool.java b/src/main/java/io/github/simplex/simplexss/ServicePool.java
index 916aad2..d9e2332 100644
--- a/src/main/java/io/github/simplex/simplexss/ServicePool.java
+++ b/src/main/java/io/github/simplex/simplexss/ServicePool.java
@@ -1,9 +1,10 @@
package io.github.simplex.simplexss;
import io.github.simplex.api.IService;
-import io.github.simplex.api.InvalidServiceException;
import org.bukkit.NamespacedKey;
+import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import reactor.core.Disposable;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
@@ -12,16 +13,31 @@ import reactor.core.scheduler.Schedulers;
import java.util.HashSet;
import java.util.Set;
-import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
public final class ServicePool {
+ /**
+ * A collection of services related to this service pool.
+ */
private final Set associatedServices;
+ /**
+ * The scheduler used to run the services in this pool.
+ */
private final Scheduler scheduler;
+ /**
+ * The key used to identify this service pool.
+ */
private final NamespacedKey name;
+ /**
+ * The default {@link NamespacedKey} used to identify unmarked services. This will cause errors if left unchecked.
+ */
private static final NamespacedKey DEFAULT = new NamespacedKey("simplex_ss", "default_service_pool");
+ /**
+ * @param name The name of this service pool.
+ * @param multithreaded Whether this service pool should be multithreaded, or operate upon a single thread.
+ */
public ServicePool(NamespacedKey name, boolean multithreaded) {
this.name = name;
this.associatedServices = new HashSet<>();
@@ -32,24 +48,44 @@ public final class ServicePool {
}
}
+ /**
+ * @return The default namespaced key to use if one is not assigned.
+ */
static NamespacedKey getDefaultNamespacedKey() {
return DEFAULT;
}
+ /**
+ * @param service Add a service to the pool's service collection.
+ */
void addService(IService service) {
getAssociatedServices().add(service);
}
+ /**
+ * @param service The service to check against this pool.
+ * @return Whether the service is registered with this pool.
+ */
boolean isValidService(IService service) {
return getAssociatedServices().contains(service);
}
+ /**
+ * @return A {@link Set} of {@link IService} objects which are registered with this pool.
+ */
+ @Contract(pure = true)
@NotNull
public Set getAssociatedServices() {
return associatedServices;
}
- public Mono startService(NamespacedKey service_name) {
+ /**
+ * @param service_name The name of the service to queue. This should be a service that is located within this service pool.
+ * If you name a service that is stored within another service pool,
+ * this method will throw an error.
+ * @return A {@link Mono} object which contains a {@link Disposable} element which can be used to destroy the registered service.
+ */
+ public @NotNull Mono queueService(NamespacedKey service_name) {
Mono service = getService(service_name);
return service.map(s -> {
if (s.isPeriodic()) {
@@ -65,7 +101,11 @@ public final class ServicePool {
});
}
- public Flux startServices() {
+ /**
+ * @return A {@link Flux} object which contains a collection of {@link Disposable} elements,
+ * which can be used to destroy the registered services using {@link ServicePool#stopServices(Flux)}.
+ */
+ public @NotNull Flux startServices() {
return Mono.just(getAssociatedServices()).flatMapMany(services -> {
Set disposables = new HashSet<>();
for (IService service : services) {
@@ -84,30 +124,58 @@ public final class ServicePool {
});
}
- public Mono stopServices(Flux disposableThread) {
+ /**
+ * @param disposableThread A {@link Flux} which contains all the services that should be disposed..
+ * @return A {@link Mono} object which can be used to stop the services.
+ */
+ public @NotNull Mono stopServices(@NotNull Flux disposableThread) {
getAssociatedServices().forEach(service -> service.stop().subscribe());
return disposableThread.doOnNext(Disposable::dispose).then();
}
- public Mono stopService(NamespacedKey service_name) {
- return getService(service_name).doOnNext(IService::stop).then();
+ /**
+ * @param service_name The name of the service to stop.
+ * @param disposable A {@link Disposable} object which contains the service that should be disposed.
+ * @return A {@link Mono} object which can be used to stop the service.
+ */
+ public @NotNull Mono stopService(@NotNull NamespacedKey service_name, @Nullable Mono disposable) {
+ getService(service_name).doOnNext(IService::stop).subscribe();
+ if (disposable != null) {
+ disposable.doOnNext(Disposable::dispose).subscribe();
+ }
+ return Mono.empty();
}
- public Mono getService(NamespacedKey service_name) {
+ /**
+ * @param service_name The name of the service to get.
+ * @return A {@link Mono} object which contains the service.
+ */
+ public @NotNull Mono getService(NamespacedKey service_name) {
return Flux.fromIterable(getAssociatedServices())
.filter(service -> service.getNamespacedKey().equals(service_name))
.next();
}
+ /**
+ * @param service The service to remove from the pool's service collection.
+ */
void removeService(IService service) {
getAssociatedServices().remove(service);
}
- public Mono recycle() {
+ /**
+ * @return This service pool after being cleared of all services.
+ * You will need to register services with this pool again before using it.
+ */
+ public @NotNull Mono recycle() {
this.getAssociatedServices().clear();
return Mono.just(this);
}
+ /**
+ * @return The {@link Scheduler} which hosts the threads for the service pool.
+ */
+ @Contract(pure = true)
public Scheduler getScheduler() {
return scheduler;
}