mirror of
https://github.com/mailscope/kumomta.git
synced 2026-10-27 08:46:13 +00:00
ready_queue: micro optimize: release lock before bumping counters
The counter bump should just be a sequence of atomic additions, but it's still desirable to do that outside of the critical section.
This commit is contained in:
@@ -113,11 +113,14 @@ impl Fifo {
|
||||
}
|
||||
|
||||
pub fn push(&self, msg: Message) -> Result<(), Message> {
|
||||
let mut list = self.list.lock();
|
||||
if list.len() + 1 > self.capacity.load(Ordering::Relaxed) {
|
||||
return Err(msg);
|
||||
{
|
||||
let mut list = self.list.lock();
|
||||
if list.len() + 1 > self.capacity.load(Ordering::Relaxed) {
|
||||
return Err(msg);
|
||||
}
|
||||
list.push_back(msg);
|
||||
}
|
||||
list.push_back(msg);
|
||||
// Increment the count after we've dropped the mutexguard on the list
|
||||
self.count.inc();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user