Package net.dv8tion.jda.api.sharding
Interface ThreadPoolProvider<T extends ExecutorService>
- Type Parameters:
T
- The type of executor
- All Known Implementing Classes:
ThreadPoolProvider.LazySharedProvider
public interface ThreadPoolProvider<T extends ExecutorService>
Called by
Every time a JDA instance is built, the manager will first call
DefaultShardManager
when building a JDA instance.
Every time a JDA instance is built, the manager will first call
provide(int)
followed by
a call to shouldShutdownAutomatically(int)
.-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic final class
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends ExecutorService>
ThreadPoolProvider.LazySharedProvider<T> lazy
(IntFunction<T> init) Provider that initializes with ashard_total
and provides the same pool to share between shards.provide
(int shardId) Provides an instance of the specified executor, or nulldefault boolean
shouldShutdownAutomatically
(int shardId) Whether the previously provided executor should be shutdown byJDA.shutdown()
.
-
Method Details
-
provide
Provides an instance of the specified executor, or null- Parameters:
shardId
- The current shard id- Returns:
- The Executor Service
-
shouldShutdownAutomatically
default boolean shouldShutdownAutomatically(int shardId) Whether the previously provided executor should be shutdown byJDA.shutdown()
.- Parameters:
shardId
- The current shard id- Returns:
- True, if the executor should be shutdown by JDA
-
lazy
@Nonnull static <T extends ExecutorService> ThreadPoolProvider.LazySharedProvider<T> lazy(@Nonnull IntFunction<T> init) Provider that initializes with ashard_total
and provides the same pool to share between shards.- Type Parameters:
T
- The type of executor- Parameters:
init
- Function to initialize the shared pool, called with the shard total- Returns:
- The lazy pool provider
-