diff options
| author | Mishio595 <[email protected]> | 2018-08-06 20:15:11 -0600 |
|---|---|---|
| committer | Mishio595 <[email protected]> | 2018-08-06 20:15:11 -0600 |
| commit | d910405d8f50fb381b7d9430b76f0b38ef4c9458 (patch) | |
| tree | 1d09b965cf0447cce84384196e19c1eba562ef7c /src/client | |
| parent | Merge branch 'upstream' (diff) | |
| parent | Dereference a destructure instead (diff) | |
| download | serenity-d910405d8f50fb381b7d9430b76f0b38ef4c9458.tar.xz serenity-d910405d8f50fb381b7d9430b76f0b38ef4c9458.zip | |
Merge branch 'upstream'
Diffstat (limited to 'src/client')
| -rw-r--r-- | src/client/dispatch.rs | 13 |
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 + }) } } }; |