aboutsummaryrefslogtreecommitdiff
path: root/src/client/context.rs
diff options
context:
space:
mode:
authoracdenisSK <[email protected]>2017-09-11 16:03:13 +0200
committeracdenisSK <[email protected]>2017-09-11 16:03:29 +0200
commit97e84fe136c5649ca3529c11790d9988dfe3bb92 (patch)
treec37c0e988d6e2495cb3ff56333c1a140a3421e8a /src/client/context.rs
parentFixed admin bypass perm to framework allowed_roles (diff)
downloadserenity-97e84fe136c5649ca3529c11790d9988dfe3bb92.tar.xz
serenity-97e84fe136c5649ca3529c11790d9988dfe3bb92.zip
Add `Context::handle`
Diffstat (limited to 'src/client/context.rs')
-rw-r--r--src/client/context.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/client/context.rs b/src/client/context.rs
index 1bd5ed7..3802134 100644
--- a/src/client/context.rs
+++ b/src/client/context.rs
@@ -3,6 +3,7 @@ use typemap::ShareMap;
use gateway::Shard;
use model::*;
use parking_lot::Mutex;
+use tokio_core::reactor::Handle;
#[cfg(feature = "cache")]
use super::CACHE;
@@ -40,14 +41,17 @@ pub struct Context {
/// Note that if you are sharding, in relevant terms, this is the shard
/// which received the event being dispatched.
pub shard: Arc<Mutex<Shard>>,
+ /// A tokio handle for spawning efficient tasks inside commands and events.
+ pub handle: Handle,
}
impl Context {
/// Create a new Context to be passed to an event handler.
- pub(crate) fn new(shard: Arc<Mutex<Shard>>, data: Arc<Mutex<ShareMap>>) -> Context {
+ pub(crate) fn new(shard: Arc<Mutex<Shard>>, data: Arc<Mutex<ShareMap>>, handle: Handle) -> Context {
Context {
data,
shard,
+ handle,
}
}