diff options
| author | Zeyla Hellyer <[email protected]> | 2017-10-09 11:30:56 -0700 |
|---|---|---|
| committer | Zeyla Hellyer <[email protected]> | 2017-10-09 11:30:56 -0700 |
| commit | 8109619184867fc843a1e73d18d37726a34f7fbf (patch) | |
| tree | 68ad2b22c2e650bc01b62e4208e21bbcc38014fb /src/client/bridge/gateway/shard_runner.rs | |
| parent | Add a threadpool to the shard runner (diff) | |
| download | serenity-8109619184867fc843a1e73d18d37726a34f7fbf.tar.xz serenity-8109619184867fc843a1e73d18d37726a34f7fbf.zip | |
Make the client threadpool user-customizable
In addition to making the threadpool used by client shards customizable
by the user, make only a single threadpool (as opposed to one per shard)
and share it across all shards.
Diffstat (limited to 'src/client/bridge/gateway/shard_runner.rs')
| -rw-r--r-- | src/client/bridge/gateway/shard_runner.rs | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/src/client/bridge/gateway/shard_runner.rs b/src/client/bridge/gateway/shard_runner.rs index 6f6b050..1b1de0e 100644 --- a/src/client/bridge/gateway/shard_runner.rs +++ b/src/client/bridge/gateway/shard_runner.rs @@ -30,16 +30,17 @@ pub struct ShardRunner<H: EventHandler + Send + Sync + 'static> { impl<H: EventHandler + Send + Sync + 'static> ShardRunner<H> { #[cfg(feature = "framework")] - pub fn new(shard: LockedShard, - manager_tx: Sender<ShardManagerMessage>, - framework: Arc<Mutex<Option<Box<Framework + Send>>>>, - data: Arc<ParkingLotMutex<ShareMap>>, - event_handler: Arc<H>) -> Self { + pub fn new( + shard: LockedShard, + manager_tx: Sender<ShardManagerMessage>, + framework: Arc<Mutex<Option<Box<Framework + Send>>>>, + data: Arc<ParkingLotMutex<ShareMap>>, + event_handler: Arc<H>, + threadpool: ThreadPool, + ) -> Self { let (tx, rx) = mpsc::channel(); let shard_info = shard.lock().shard_info(); - let name = format!("threadpool {:?}", shard_info); - Self { runner_rx: rx, runner_tx: tx, @@ -49,20 +50,21 @@ impl<H: EventHandler + Send + Sync + 'static> ShardRunner<H> { manager_tx, shard, shard_info, - threadpool: ThreadPool::with_name(name, 15), + threadpool, } } #[cfg(not(feature = "framework"))] - pub fn new(shard: LockedShard, - manager_tx: Sender<ShardManagerMessage>, - data: Arc<ParkingLotMutex<ShareMap>>, - event_handler: Arc<H>) -> Self { + pub fn new( + shard: LockedShard, + manager_tx: Sender<ShardManagerMessage>, + data: Arc<ParkingLotMutex<ShareMap>>, + event_handler: Arc<H>, + threadpool: ThreadPool, + ) -> Self { let (tx, rx) = mpsc::channel(); let shard_info = shard.lock().shard_info(); - let name = format!("threadpool {:?}", shard_info); - Self { runner_rx: rx, runner_tx: tx, @@ -71,7 +73,7 @@ impl<H: EventHandler + Send + Sync + 'static> ShardRunner<H> { manager_tx, shard, shard_info, - threadpool: ThreadPool::with_name(name, 15), + threadpool, } } |