aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErk- <[email protected]>2018-10-30 15:08:49 +0100
committerLakelezz <[email protected]>2018-10-30 15:08:49 +0100
commit41ff44ba4e4bdd7aa77bfbfce201b89c7990d9e4 (patch)
treec57cb618afd81fc513d84325a7c0606d526ce48c
parentAdd guideline about maximum characters per line (#422) (diff)
downloadserenity-41ff44ba4e4bdd7aa77bfbfce201b89c7990d9e4.tar.xz
serenity-41ff44ba4e4bdd7aa77bfbfce201b89c7990d9e4.zip
Fix cache write lock timer (#423)
-rw-r--r--src/client/dispatch.rs17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/client/dispatch.rs b/src/client/dispatch.rs
index 3cc22e4..7ac8148 100644
--- a/src/client/dispatch.rs
+++ b/src/client/dispatch.rs
@@ -36,19 +36,20 @@ macro_rules! update {
{
#[cfg(feature = "cache")]
{
- if let Some(duration) = *CACHE_TRY_WRITE_DURATION {
- CACHE.try_write_for(duration)
- .and_then(|mut lock| lock.update(&mut $event))
- .or_else(|| {
+ match *CACHE_TRY_WRITE_DURATION {
+ Some(duration) => {
+ if let Some(mut lock) = CACHE.try_write_for(duration) {
+ lock.update(&mut $event)
+ } else {
warn!(
"[dispatch] Possible deadlock: couldn't unlock cache to update with event: {:?}",
$event,
);
-
None
- })
- } else {
- CACHE.write().update(&mut $event)
+ }},
+ None => {
+ CACHE.write().update(&mut $event)
+ },
}
}
}