-
-
Save TBS1996/576844f8ee11576e2a290be95f6bd017 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if val | |
.read() | |
.unwrap_or_else(|e| e.into_inner()) | |
.redis_call_in_progress | |
.swap(true, Ordering::SeqCst) | |
{ | |
return Ok(()); | |
} | |
match self.call_redis(quota, client, quantity) { | |
Ok((new_budget, redis_value)) => { | |
let mut lock = val.write().unwrap_or_else(|e| e.into_inner()); | |
lock.update(new_budget, redis_value, current_slot); | |
lock.redis_call_in_progress.store(false, Ordering::SeqCst); | |
} | |
Err(e) => { | |
val.read() | |
.unwrap_or_else(|e| e.into_inner()) | |
.redis_call_in_progress | |
.store(false, Ordering::SeqCst); | |
return Err(e); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment