Use BlockingSpawner
This commit is contained in:
parent
fdacb7bc16
commit
7e8935388c
1 changed files with 8 additions and 6 deletions
|
|
@ -12,13 +12,12 @@ use anyhow::Context;
|
||||||
use dashmap::DashMap;
|
use dashmap::DashMap;
|
||||||
|
|
||||||
use librqbit_core::lengths::{CurrentPiece, Lengths, ValidPieceIndex};
|
use librqbit_core::lengths::{CurrentPiece, Lengths, ValidPieceIndex};
|
||||||
use tokio::{
|
use tokio::io::{AsyncRead, AsyncSeek};
|
||||||
io::{AsyncRead, AsyncSeek},
|
|
||||||
task::block_in_place,
|
|
||||||
};
|
|
||||||
use tracing::{debug, trace};
|
use tracing::{debug, trace};
|
||||||
|
|
||||||
use crate::{file_info::FileInfo, storage::TorrentStorage, ManagedTorrent};
|
use crate::{
|
||||||
|
file_info::FileInfo, spawn_utils::BlockingSpawner, storage::TorrentStorage, ManagedTorrent,
|
||||||
|
};
|
||||||
|
|
||||||
use super::ManagedTorrentHandle;
|
use super::ManagedTorrentHandle;
|
||||||
|
|
||||||
|
|
@ -139,6 +138,8 @@ pub struct FileStream {
|
||||||
// file params
|
// file params
|
||||||
file_len: u64,
|
file_len: u64,
|
||||||
file_torrent_abs_offset: u64,
|
file_torrent_abs_offset: u64,
|
||||||
|
|
||||||
|
spawner: BlockingSpawner,
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! map_io_err {
|
macro_rules! map_io_err {
|
||||||
|
|
@ -214,7 +215,7 @@ impl AsyncRead for FileStream {
|
||||||
"will write bytes"
|
"will write bytes"
|
||||||
);
|
);
|
||||||
|
|
||||||
poll_try_io!(poll_try_io!(block_in_place(|| {
|
poll_try_io!(poll_try_io!(self.spawner.spawn_block_in_place(|| {
|
||||||
self.torrent
|
self.torrent
|
||||||
.with_storage_and_file(self.file_id, |files, _fi| {
|
.with_storage_and_file(self.file_id, |files, _fi| {
|
||||||
files.pread_exact(self.file_id, self.position, buf)?;
|
files.pread_exact(self.file_id, self.position, buf)?;
|
||||||
|
|
@ -327,6 +328,7 @@ impl ManagedTorrent {
|
||||||
file_len: fd_len,
|
file_len: fd_len,
|
||||||
file_torrent_abs_offset: fd_offset,
|
file_torrent_abs_offset: fd_offset,
|
||||||
torrent: self,
|
torrent: self,
|
||||||
|
spawner: BlockingSpawner::default(),
|
||||||
};
|
};
|
||||||
s.torrent.maybe_reconnect_needed_peers_for_file(file_id);
|
s.torrent.maybe_reconnect_needed_peers_for_file(file_id);
|
||||||
streams.streams.insert(
|
streams.streams.insert(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue