Add per piece locks
This commit is contained in:
parent
e53f5a7f23
commit
ca9afa8535
1 changed files with 6 additions and 0 deletions
|
|
@ -161,6 +161,8 @@ pub struct TorrentStateLive {
|
||||||
|
|
||||||
pub(crate) files: FileStorage,
|
pub(crate) files: FileStorage,
|
||||||
|
|
||||||
|
per_piece_locks: Vec<RwLock<()>>,
|
||||||
|
|
||||||
stats: AtomicStats,
|
stats: AtomicStats,
|
||||||
lengths: Lengths,
|
lengths: Lengths,
|
||||||
|
|
||||||
|
|
@ -212,6 +214,7 @@ impl TorrentStateLive {
|
||||||
peers: Default::default(),
|
peers: Default::default(),
|
||||||
locked: RwLock::new(TorrentStateLocked {
|
locked: RwLock::new(TorrentStateLocked {
|
||||||
chunks: Some(paused.chunk_tracker),
|
chunks: Some(paused.chunk_tracker),
|
||||||
|
// TODO: move under per_piece_locks
|
||||||
inflight_pieces: Default::default(),
|
inflight_pieces: Default::default(),
|
||||||
file_priorities,
|
file_priorities,
|
||||||
fatal_errors_tx: Some(fatal_errors_tx),
|
fatal_errors_tx: Some(fatal_errors_tx),
|
||||||
|
|
@ -229,6 +232,9 @@ impl TorrentStateLive {
|
||||||
up_speed_estimator,
|
up_speed_estimator,
|
||||||
cancellation_token,
|
cancellation_token,
|
||||||
streams: paused.streams,
|
streams: paused.streams,
|
||||||
|
per_piece_locks: (0..lengths.total_pieces())
|
||||||
|
.map(|_| RwLock::new(()))
|
||||||
|
.collect(),
|
||||||
});
|
});
|
||||||
|
|
||||||
state.spawn(
|
state.spawn(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue