mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-04-01 18:25:30 +00:00
udp: add cleaning worker
This commit is contained in:
parent
6d7ffd40ae
commit
c4fd3c9e83
6 changed files with 57 additions and 52 deletions
|
|
@ -71,6 +71,29 @@ pub fn run(config: Config) -> ::anyhow::Result<()> {
|
|||
join_handles.push((WorkerType::Socket(i), handle));
|
||||
}
|
||||
|
||||
{
|
||||
let state = state.clone();
|
||||
let config = config.clone();
|
||||
let statistics = statistics.swarm.clone();
|
||||
let statistics_sender = statistics_sender.clone();
|
||||
|
||||
let handle = Builder::new().name("cleaning".into()).spawn(move || loop {
|
||||
sleep(Duration::from_secs(
|
||||
config.cleaning.torrent_cleaning_interval,
|
||||
));
|
||||
|
||||
state.torrent_maps.clean_and_update_statistics(
|
||||
&config,
|
||||
&statistics,
|
||||
&statistics_sender,
|
||||
&state.access_list,
|
||||
state.server_start_instant,
|
||||
);
|
||||
})?;
|
||||
|
||||
join_handles.push((WorkerType::Cleaning, handle));
|
||||
}
|
||||
|
||||
if config.statistics.active() {
|
||||
let state = state.clone();
|
||||
let config = config.clone();
|
||||
|
|
@ -142,14 +165,6 @@ pub fn run(config: Config) -> ::anyhow::Result<()> {
|
|||
join_handles.push((WorkerType::Signals, handle));
|
||||
}
|
||||
|
||||
#[cfg(feature = "cpu-pinning")]
|
||||
pin_current_if_configured_to(
|
||||
&config.cpu_pinning,
|
||||
config.socket_workers,
|
||||
config.swarm_workers,
|
||||
WorkerIndex::Util,
|
||||
);
|
||||
|
||||
loop {
|
||||
for (i, (_, handle)) in join_handles.iter().enumerate() {
|
||||
if handle.is_finished() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue