use futures_intrusive::sync::SharedSemaphore;
const MAX_SIMULTANEOUS_LOADED_MB: usize = 50;
const MAX_SIMULTANEOUS_CREATE_CHUNK: usize = 50;
const MAX_SIMULTANEOUS_CREATE_CHUNK_CALLS: usize = 25;
const MAX_SIMULTANEOUS_CREATE_CHUNK_WAITS: usize = 25;
#[derive(Debug)]
pub(crate) struct Semaphores {
pub file: SharedSemaphore,
pub create_chunk: SharedSemaphore,
pub create_chunk_call: SharedSemaphore,
pub create_chunk_wait: SharedSemaphore,
}
impl Semaphores {
pub fn new() -> Semaphores {
let file = SharedSemaphore::new(true, MAX_SIMULTANEOUS_LOADED_MB);
let create_chunk = SharedSemaphore::new(true, MAX_SIMULTANEOUS_CREATE_CHUNK);
let create_chunk_call = SharedSemaphore::new(true, MAX_SIMULTANEOUS_CREATE_CHUNK_CALLS);
let create_chunk_wait = SharedSemaphore::new(true, MAX_SIMULTANEOUS_CREATE_CHUNK_WAITS);
Semaphores {
file,
create_chunk,
create_chunk_call,
create_chunk_wait,
}
}
}