Class ServicePool

java.lang.Object
io.github.simplex.simplexss.ServicePool

public final class ServicePool extends Object
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final Set<IService>
    A collection of services related to this service pool.
    private static final org.bukkit.NamespacedKey
    The default NamespacedKey used to identify unmarked services.
    private final org.bukkit.NamespacedKey
    The key used to identify this service pool.
    private final reactor.core.scheduler.Scheduler
    The scheduler used to run the services in this pool.
  • Constructor Summary

    Constructors
    Constructor
    Description
    ServicePool(org.bukkit.NamespacedKey name, boolean multithreaded)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    (package private) void
     
    @NotNull Set<IService>
     
    (package private) static org.bukkit.NamespacedKey
     
    reactor.core.scheduler.Scheduler
     
    @NotNull reactor.core.publisher.Mono<IService>
    getService(org.bukkit.NamespacedKey service_name)
     
    (package private) boolean
     
    @NotNull reactor.core.publisher.Mono<reactor.core.Disposable>
    queueService(org.bukkit.NamespacedKey service_name)
     
    @NotNull reactor.core.publisher.Mono<ServicePool>
     
    (package private) void
     
    @NotNull reactor.core.publisher.Flux<reactor.core.Disposable>
     
    @NotNull reactor.core.publisher.Mono<Void>
    stopService(@NotNull org.bukkit.NamespacedKey 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)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • associatedServices

      private final Set<IService> associatedServices
      A collection of services related to this service pool.
    • scheduler

      private final reactor.core.scheduler.Scheduler scheduler
      The scheduler used to run the services in this pool.
    • name

      private final org.bukkit.NamespacedKey name
      The key used to identify this service pool.
    • DEFAULT

      private static final org.bukkit.NamespacedKey DEFAULT
      The default NamespacedKey used to identify unmarked services. This will cause errors if left unchecked.
  • Constructor Details

    • ServicePool

      public ServicePool(org.bukkit.NamespacedKey name, boolean multithreaded)
      Parameters:
      name - The name of this service pool.
      multithreaded - Whether this service pool should be multithreaded, or operate upon a single thread.
  • Method Details

    • getDefaultNamespacedKey

      static org.bukkit.NamespacedKey getDefaultNamespacedKey()
      Returns:
      The default namespaced key to use if one is not assigned.
    • addService

      void addService(IService service)
      Parameters:
      service - Add a service to the pool's service collection.
    • isValidService

      boolean isValidService(IService service)
      Parameters:
      service - The service to check against this pool.
      Returns:
      Whether the service is registered with this pool.
    • getAssociatedServices

      @Contract(pure=true) @NotNull public @NotNull Set<IService> getAssociatedServices()
      Returns:
      A Set of IService objects which are registered with this pool.
    • queueService

      @NotNull public @NotNull reactor.core.publisher.Mono<reactor.core.Disposable> queueService(org.bukkit.NamespacedKey service_name)
      Parameters:
      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.
    • startServices

      @NotNull public @NotNull reactor.core.publisher.Flux<reactor.core.Disposable> startServices()
      Returns:
      A Flux object which contains a collection of Disposable elements, which can be used to destroy the registered services using stopServices(Flux<Disposable>).
    • stopServices

      @NotNull public @NotNull reactor.core.publisher.Mono<Void> stopServices(@NotNull @NotNull reactor.core.publisher.Flux<reactor.core.Disposable> disposableThread)
      Parameters:
      disposableThread - A reactor.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 org.bukkit.NamespacedKey service_name, @Nullable @Nullable reactor.core.publisher.Mono<reactor.core.Disposable> disposable)
      Parameters:
      service_name - The name of the service to stop.
      disposable - A Disposable object 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

      @NotNull public @NotNull reactor.core.publisher.Mono<IService> getService(org.bukkit.NamespacedKey service_name)
      Parameters:
      service_name - The name of the service to get.
      Returns:
      A Mono object which contains the service.
    • removeService

      void removeService(IService service)
      Parameters:
      service - The service to remove from the pool's service collection.
    • recycle

      @NotNull public @NotNull reactor.core.publisher.Mono<ServicePool> 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 Scheduler which hosts the threads for the service pool.