Class ExecutableService
java.lang.Object
io.github.simplexdevelopment.scheduler.ExecutableService
- All Implemented Interfaces:
Identifier
,IService
,Runnable
- Direct Known Subclasses:
ServiceImpl
-
Constructor Summary
ConstructorDescriptionExecutableService
(@NotNull String service_name) Creates a new instance of an executable service.ExecutableService
(@Nullable ServicePool parentPool, @NotNull String service_name) Creates a new instance of an executable service.ExecutableService
(@Nullable ServicePool parentPool, @NotNull String service_name, @NotNull Long delay, @NotNull Long period, @NotNull Boolean repeating) Creates a new instance of an executable service.ExecutableService
(@Nullable ServicePool parentPool, @NotNull String service_name, @Nullable Long delay) Creates a new instance of an executable service.ExecutableService
(@Nullable ServicePool parentPool, @NotNull String service_name, @Nullable Long delay, @Nullable Long period, @NotNull Boolean repeating, @NotNull Boolean mayInterruptWhenRunning) Creates a new instance of an executable service. -
Method Summary
Modifier and TypeMethodDescriptionlong
getDelay()
getName()
reactor.core.publisher.Mono<ServicePool>
long
boolean
Cancels the execution of this service.boolean
reactor.core.publisher.Mono<Void>
setCancelled
(boolean cancel) Cancels the execution of this service.reactor.core.publisher.Mono<Void>
setParentPool
(ServicePool servicePool) Sets the parent pool for this service.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.github.simplexdevelopment.api.Identifier
getNumericalId, getUniqueId
-
Constructor Details
-
ExecutableService
Creates a new instance of an executable service. Each service is registered with aString
, to allow for easy identification within the associatedServicePool
.- Parameters:
service_name
- A namespaced key which can be used to identify the service.
-
ExecutableService
public ExecutableService(@Nullable @Nullable ServicePool parentPool, @NotNull @NotNull String service_name) Creates a new instance of an executable service. Each service is registered with aString
, to allow for easy identification within the associatedServicePool
.- Parameters:
parentPool
- TheServicePool
which this service is executing on.service_name
- A namespaced key which can be used to identify the service.
-
ExecutableService
public ExecutableService(@Nullable @Nullable ServicePool parentPool, @NotNull @NotNull String service_name, @Nullable @Nullable Long delay) 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 aString
, to allow for easy identification within the associatedServicePool
.- Parameters:
parentPool
- TheServicePool
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.
-
ExecutableService
public ExecutableService(@Nullable @Nullable ServicePool parentPool, @NotNull @NotNull String service_name, @NotNull @NotNull Long delay, @NotNull @NotNull Long period, @NotNull @NotNull Boolean repeating) 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 flaggedrepeating
as true, and the period is null, then the period will automatically be set to 20 minutes. Each service is registered with aString
, to allow for easy identification within the associatedServicePool
.- Parameters:
parentPool
- TheServicePool
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.
-
ExecutableService
public ExecutableService(@Nullable @Nullable ServicePool parentPool, @NotNull @NotNull String service_name, @Nullable @Nullable Long delay, @Nullable @Nullable Long period, @NotNull @NotNull Boolean repeating, @NotNull @NotNull Boolean mayInterruptWhenRunning) 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 flaggedrepeating
as true, and the period is null, then the period will automatically be set to 20 minutes. Each service is registered with aString
, to allow for easy identification within the associatedServicePool
.- Parameters:
parentPool
- TheServicePool
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.mayInterruptWhenRunning
- If the service can be cancelled during execution.
-
-
Method Details
-
getDelay
public long getDelay() -
getPeriod
public long getPeriod() -
isPeriodic
public boolean isPeriodic()- Specified by:
isPeriodic
in interfaceIService
- Returns:
- If the service should be scheduled for repeated executions or not.
-
isCancelled
public boolean isCancelled()Cancels the execution of this service.- Returns:
- true if the service was cancelled, false if not.
-
setCancelled
Cancels the execution of this service.- Parameters:
cancel
- Whether the service should be cancelled or not.
-
getParentPool
- Specified by:
getParentPool
in interfaceIService
- Returns:
- The
ServicePool
which this service is executing on.
-
getName
- Specified by:
getName
in interfaceIdentifier
- Returns:
- The name of the identifiable object in a readable format.
-
setParentPool
Description copied from interface:IService
Sets the parent pool for this service.- Specified by:
setParentPool
in interfaceIService
- Parameters:
servicePool
- The service pool to attach this service to.- Returns:
- An encapsulated Mono object representing the set operation.
-