http_type/task/struct.rs
1use crate::*;
2
3/// Task manager for handling async tasks across worker threads.
4///
5/// This structure manages a pool of task senders distributed across
6/// multiple worker threads, enabling efficient round-robin task scheduling
7/// with event-driven wake-up mechanism.
8#[derive(Clone, CustomDebug, Data, DisplayDebug)]
9pub struct Task {
10 /// Pool of unbounded senders for distributing tasks to worker threads.
11 #[get(pub)]
12 #[get_mut(pub)]
13 #[set(pub)]
14 pub pool: Vec<UnboundedSender<AsyncTask>>,
15 /// Atomic counter for round-robin task distribution across workers.
16 #[get(pub)]
17 #[get_mut(pub)]
18 #[set(pub)]
19 pub counter: Arc<AtomicUsize>,
20 /// Flag indicating whether the task pool should shut down.
21 #[get(pub)]
22 #[get_mut(pub)]
23 #[set(pub)]
24 pub shutdown: Arc<AtomicBool>,
25 /// Notification handles for precise wake-up of specific workers.
26 #[get(pub)]
27 #[get_mut(pub)]
28 #[set(pub)]
29 pub notifies: Vec<Arc<Notify>>,
30}