summaryrefslogtreecommitdiff
path: root/src/ot_clean.h
blob: 059279122c74c24b459d90971d9652d7f9525515 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/* This software was written by Dirk Engling <erdgeist@erdgeist.org>
   It is considered beerware. Prost. Skol. Cheers or whatever. */

#ifndef OT_CLEAN_H__
#define OT_CLEAN_H__

#include "trackerlogic.h"

/* The amount of time a clean cycle should take */
#define OT_CLEAN_INTERVAL_MINUTES 2

/* How often the cleaner may wake. A full sweep takes OT_CLEAN_INTERVAL_MINUTES.
   The clean operations per wake is goverend by OT_BUCKET_COUNT_BITS,
   set by the Makefile.
   At the default of 1024 buckets this works out at one bucket every
   117 ms. */
#define OT_CLEAN_MAX_WAKES_PER_SECOND 10

#define OT_CLEAN_WAKE_BUDGET      ((OT_CLEAN_INTERVAL_MINUTES) * 60 * (OT_CLEAN_MAX_WAKES_PER_SECOND))
#define OT_CLEAN_BUCKETS_PER_WAKE (((OT_BUCKET_COUNT) + (OT_CLEAN_WAKE_BUDGET) - 1) / (OT_CLEAN_WAKE_BUDGET))
#define OT_CLEAN_WAKES            ((OT_BUCKET_COUNT) / (OT_CLEAN_BUCKETS_PER_WAKE))
#define OT_CLEAN_SLEEP            (((OT_CLEAN_INTERVAL_MINUTES) * 60 * 1000000) / (OT_CLEAN_WAKES))

void clean_init(void);
void clean_deinit(void);
int  clean_single_torrent(ot_torrent *torrent);

#endif