diff options
| author | Zeyla Hellyer <[email protected]> | 2017-11-13 13:28:08 -0800 |
|---|---|---|
| committer | Zeyla Hellyer <[email protected]> | 2017-11-13 13:29:03 -0800 |
| commit | f2c21ef5b15ef1f345cdc30f4b793e55905f15f4 (patch) | |
| tree | 33a0d5e68976a31d750cefaf78df8b2577b63578 /src/framework/mod.rs | |
| parent | Fix strange behaviour when the prefix has spaces (#215) (diff) | |
| download | serenity-f2c21ef5b15ef1f345cdc30f4b793e55905f15f4.tar.xz serenity-f2c21ef5b15ef1f345cdc30f4b793e55905f15f4.zip | |
Use the threadpool for framework command execution
Instead of executing framework commands in the shard runner thread
(potentially blocking the shard runner from reading new messages over
the websocket and heartbeating), dispatch framework commands to the
shard runner's threadpool.
Diffstat (limited to 'src/framework/mod.rs')
| -rw-r--r-- | src/framework/mod.rs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/framework/mod.rs b/src/framework/mod.rs index 85ae6f4..c5ddb04 100644 --- a/src/framework/mod.rs +++ b/src/framework/mod.rs @@ -62,13 +62,14 @@ pub use self::standard::StandardFramework; use client::Context; use model::Message; +use threadpool::ThreadPool; #[cfg(feature = "standard_framework")] use model::UserId; /// This trait allows for serenity to either use its builtin framework, or yours. pub trait Framework { - fn dispatch(&mut self, Context, Message); + fn dispatch(&mut self, Context, Message, &ThreadPool); #[doc(hidden)] #[cfg(feature = "standard_framework")] @@ -76,8 +77,8 @@ pub trait Framework { } impl<F: Framework + ?Sized> Framework for Box<F> { - fn dispatch(&mut self, ctx: Context, msg: Message) { - (**self).dispatch(ctx, msg); + fn dispatch(&mut self, ctx: Context, msg: Message, threadpool: &ThreadPool) { + (**self).dispatch(ctx, msg, threadpool); } #[cfg(feature = "standard_framework")] @@ -87,8 +88,8 @@ impl<F: Framework + ?Sized> Framework for Box<F> { } impl<'a, F: Framework + ?Sized> Framework for &'a mut F { - fn dispatch(&mut self, ctx: Context, msg: Message) { - (**self).dispatch(ctx, msg); + fn dispatch(&mut self, ctx: Context, msg: Message, threadpool: &ThreadPool) { + (**self).dispatch(ctx, msg, threadpool); } #[cfg(feature = "standard_framework")] |