aboutsummaryrefslogtreecommitdiff
path: root/src/client/bridge/gateway/shard_manager.rs
diff options
context:
space:
mode:
authorZeyla Hellyer <[email protected]>2017-10-09 11:30:56 -0700
committerZeyla Hellyer <[email protected]>2017-10-09 11:30:56 -0700
commit8109619184867fc843a1e73d18d37726a34f7fbf (patch)
tree68ad2b22c2e650bc01b62e4208e21bbcc38014fb /src/client/bridge/gateway/shard_manager.rs
parentAdd a threadpool to the shard runner (diff)
downloadserenity-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_manager.rs')
-rw-r--r--src/client/bridge/gateway/shard_manager.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/client/bridge/gateway/shard_manager.rs b/src/client/bridge/gateway/shard_manager.rs
index 5dbe0c3..2068bef 100644
--- a/src/client/bridge/gateway/shard_manager.rs
+++ b/src/client/bridge/gateway/shard_manager.rs
@@ -12,6 +12,7 @@ use super::{
ShardQueuerMessage,
ShardRunnerInfo,
};
+use threadpool::ThreadPool;
use typemap::ShareMap;
#[cfg(feature = "framework")]
@@ -40,6 +41,7 @@ impl ShardManager {
data: Arc<ParkingLotMutex<ShareMap>>,
event_handler: Arc<H>,
framework: Arc<Mutex<Option<Box<Framework + Send>>>>,
+ threadpool: ThreadPool,
) -> Self where H: EventHandler + Send + Sync + 'static {
let (thread_tx, thread_rx) = mpsc::channel();
let (shard_queue_tx, shard_queue_rx) = mpsc::channel();
@@ -56,6 +58,7 @@ impl ShardManager {
rx: shard_queue_rx,
token: token.clone(),
ws_url: ws_url.clone(),
+ threadpool,
};
thread::spawn(move || {
@@ -81,6 +84,7 @@ impl ShardManager {
token: Arc<Mutex<String>>,
data: Arc<ParkingLotMutex<ShareMap>>,
event_handler: Arc<H>,
+ threadpool: ThreadPool,
) -> Self where H: EventHandler + Send + Sync + 'static {
let (thread_tx, thread_rx) = mpsc::channel();
let (shard_queue_tx, shard_queue_rx) = mpsc::channel();
@@ -96,6 +100,7 @@ impl ShardManager {
rx: shard_queue_rx,
token: token.clone(),
ws_url: ws_url.clone(),
+ threadpool,
};
thread::spawn(move || {