aboutsummaryrefslogtreecommitdiff
path: root/src/client
diff options
context:
space:
mode:
authorMishio595 <[email protected]>2018-08-06 20:15:11 -0600
committerMishio595 <[email protected]>2018-08-06 20:15:11 -0600
commitd910405d8f50fb381b7d9430b76f0b38ef4c9458 (patch)
tree1d09b965cf0447cce84384196e19c1eba562ef7c /src/client
parentMerge branch 'upstream' (diff)
parentDereference a destructure instead (diff)
downloadserenity-d910405d8f50fb381b7d9430b76f0b38ef4c9458.tar.xz
serenity-d910405d8f50fb381b7d9430b76f0b38ef4c9458.zip
Merge branch 'upstream'
Diffstat (limited to 'src/client')
-rw-r--r--src/client/dispatch.rs13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/client/dispatch.rs b/src/client/dispatch.rs
index b8c5610..2bbe344 100644
--- a/src/client/dispatch.rs
+++ b/src/client/dispatch.rs
@@ -19,6 +19,8 @@ use typemap::ShareMap;
use framework::Framework;
#[cfg(feature = "cache")]
use model::id::GuildId;
+#[cfg(feature = "cache")]
+use std::time::Duration;
#[cfg(feature = "cache")]
use super::CACHE;
@@ -28,7 +30,16 @@ macro_rules! update {
{
#[cfg(feature = "cache")]
{
- CACHE.write().update(&mut $event)
+ CACHE.try_write_for(Duration::from_millis(10))
+ .and_then(|mut lock| lock.update(&mut $event))
+ .or_else(|| {
+ warn!(
+ "[dispatch] Possible deadlock: couldn't unlock cache to update with event: {:?}",
+ $event,
+ );
+
+ None
+ })
}
}
};