Class ServicePool
java.lang.Object
io.github.simplexdevelopment.scheduler.ServicePool
-
Field Summary
FieldsModifier and TypeFieldDescriptionA collection of services related to this service pool.private static final StringThe defaultStringused to identify unmarked services.private final StringThe name used to identify this service pool.private final reactor.core.scheduler.SchedulerThe scheduler used to run the services in this pool. -
Constructor Summary
ConstructorsConstructorDescriptionServicePool(String name, boolean multithreaded) This will create a new instance of a Service Pool with aScheduleras its main scheduler.ServicePool(String name, org.bukkit.plugin.java.JavaPlugin plugin) This will create a new instance of a Service Pool with theReactorBukkitScheduleras its main scheduler. -
Method Summary
Modifier and TypeMethodDescription(package private) voidaddService(IService service) (package private) static Stringreactor.core.scheduler.Scheduler@NotNull reactor.core.publisher.Mono<IService>getService(String service_name) (package private) booleanisValidService(IService service) @NotNull reactor.core.publisher.Mono<reactor.core.Disposable>queueService(IService service) @NotNull reactor.core.publisher.Mono<ServicePool>recycle()(package private) voidremoveService(IService service) @NotNull reactor.core.publisher.Flux<reactor.core.Disposable>@NotNull reactor.core.publisher.Mono<Void>stopService(@NotNull String service_name, @Nullable reactor.core.publisher.Mono<reactor.core.Disposable> disposable) @NotNull reactor.core.publisher.Mono<Void>stopServices(@NotNull reactor.core.publisher.Flux<reactor.core.Disposable> disposableThread)
-
Field Details
-
DEFAULT
The defaultStringused to identify unmarked services. This will cause errors if left unchecked.- See Also:
-
associatedServices
A collection of services related to this service pool. -
scheduler
private final reactor.core.scheduler.Scheduler schedulerThe scheduler used to run the services in this pool. -
name
The name used to identify this service pool.
-
-
Constructor Details
-
ServicePool
This will create a new instance of a Service Pool with aScheduleras its main scheduler. This should be used if you'd like to execute tasks without communicating on the main server thread.- Parameters:
name- The name of this service pool.multithreaded- Whether this service pool should be multithreaded, or operate upon a single thread.
-
ServicePool
This will create a new instance of a Service Pool with theReactorBukkitScheduleras its main scheduler. This should be used if you'd like to execute tasks while communicating on the main server thread.- Parameters:
name- The name of this service pool.
-
-
Method Details
-
getDefaultNamespacedKey
- Returns:
- The default namespaced key to use if one is not assigned.
-
addService
- Parameters:
service- Add a service to the pool's service collection.
-
isValidService
- Parameters:
service- The service to check against this pool.- Returns:
- Whether the service is registered with this pool.
-
getAssociatedServices
-
queueService
@NotNull public @NotNull reactor.core.publisher.Mono<reactor.core.Disposable> queueService(IService service) - Parameters:
service- 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
Monoobject which contains aDisposableelement which can be used to destroy the registered service.
-
startServices
@NotNull public @NotNull reactor.core.publisher.Flux<reactor.core.Disposable> startServices()- Returns:
- A
Fluxobject which contains a collection ofDisposableelements, which can be used to destroy the registered services usingstopServices(Flux).
-
stopServices
@NotNull public @NotNull reactor.core.publisher.Mono<Void> stopServices(@NotNull @NotNull reactor.core.publisher.Flux<reactor.core.Disposable> disposableThread) - Parameters:
disposableThread- Areactor.core.publisher.Flux<reactor.core.Disposable>which contains all the services that should be disposed..- Returns:
- A
reactor.core.publisher.Mono<Void>object which can be used to stop the services.
-
stopService
@NotNull public @NotNull reactor.core.publisher.Mono<Void> stopService(@NotNull @NotNull String service_name, @Nullable @Nullable reactor.core.publisher.Mono<reactor.core.Disposable> disposable) - Parameters:
service_name- The name of the service to stop.disposable- ADisposableobject which contains the service that should be disposed.- Returns:
- A
reactor.core.publisher.Mono<Void>object which can be used to stop the service.
-
getService
- Parameters:
service_name- The name of the service to get.- Returns:
- A
Monoobject which contains the service.
-
removeService
- Parameters:
service- The service to remove from the pool's service collection.
-
recycle
- Returns:
- This service pool after being cleared of all services. You will need to register services with this pool again before using it.
-
getScheduler
@Contract(pure=true) public reactor.core.scheduler.Scheduler getScheduler()- Returns:
- The
Schedulerwhich hosts the threads for the service pool.
-