1
0
Fork 0
mirror of https://github.com/librespot-org/librespot.git synced 2025-10-06 03:50:06 +02:00

Improve lock ordering and contention

This commit is contained in:
Roderick van Domburg 2022-01-05 20:44:08 +01:00
parent 5c2b5a21c1
commit 1a7c440bd7
No known key found for this signature in database
GPG key ID: A9EF5222A26F0451
6 changed files with 82 additions and 48 deletions

View file

@ -1,11 +1,10 @@
use std::{
cmp::{max, min},
io::{Seek, SeekFrom, Write},
sync::{atomic, Arc},
sync::{atomic::Ordering, Arc},
time::{Duration, Instant},
};
use atomic::Ordering;
use bytes::Bytes;
use futures_util::StreamExt;
use hyper::StatusCode;
@ -231,7 +230,7 @@ impl AudioFileFetch {
// download data from after the current read position first
let mut tail_end = RangeSet::new();
let read_position = self.shared.read_position.load(Ordering::Relaxed);
let read_position = self.shared.read_position.load(Ordering::Acquire);
tail_end.add_range(&Range::new(
read_position,
self.shared.file_size - read_position,