[][src]Struct liriodendron::task::tasksmanager::TasksManager

pub struct TasksManager {
    nb_running_threads: Arc<Mutex<usize>>,
    waiting_tasks: Arc<Mutex<usize>>,
    is_sending: Arc<Mutex<bool>>,
    threadpool: ThreadPool,
    sender: Sender<Option<(ThreadId, (u16, u16))>>,
    receiver: Receiver<Option<(ThreadId, (u16, u16))>>,
    tasks: VecDeque<Box<dyn Task + Send>>,
    todo_tasks: usize,
    done_tasks: usize,
    threads_monitor: HashMap<ThreadId, (u16, u16)>,
    threads_number: usize,
    max_tasks: usize,
}

Multi-threaded struct to support expensive users queries and avoid blocking tasks

Fields

nb_running_threads: Arc<Mutex<usize>>

Running threads counter

waiting_tasks: Arc<Mutex<usize>>

Queue's length

is_sending: Arc<Mutex<bool>>

When true, threads send their progression

threadpool: ThreadPoolsender: Sender<Option<(ThreadId, (u16, u16))>>receiver: Receiver<Option<(ThreadId, (u16, u16))>>tasks: VecDeque<Box<dyn Task + Send>>

Waiting tasks are stocked in this queue

todo_tasks: usizedone_tasks: usizethreads_monitor: HashMap<ThreadId, (u16, u16)>

Stocks threads' progression

threads_number: usize

Customizable member

max_tasks: usize

Customizable member

Methods

impl TasksManager[src]

pub fn new(threads_number: usize, max_tasks: usize) -> TasksManager[src]

pub fn new_generation_task(&mut self, log: &Log) -> (Result<()>, bool)[src]

fn get_nb_running_threads(&self) -> usize[src]

pub fn get_todo_and_max_tasks(&self) -> (usize, usize)[src]

pub fn get_done_and_todo_tasks(&self) -> (usize, usize)[src]

pub fn check_queue(&mut self)[src]

Checks if a task is in the queue. If a thread is available, it runs the task and pop it from the queue.

pub fn start_sender_channel(&mut self)[src]

pub fn compute_todotasks(&mut self)[src]

pub fn spawn_unlocking_thread(&self)[src]

Unlocks a blocking std::sync::mpsc::Receiver.recv() call

pub fn shutdown(self)[src]

pub fn get_threads_monitor(&self) -> &HashMap<ThreadId, (u16, u16)>[src]

pub fn is_running(&mut self) -> bool[src]

While the receiver is receiving data from the threadpool, a thread is running

Auto Trait Implementations

impl !RefUnwindSafe for TasksManager

impl Send for TasksManager

impl !Sync for TasksManager

impl Unpin for TasksManager

impl !UnwindSafe for TasksManager

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> SetParameter for T

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,