Skip to main content

ExecutorInner

Struct ExecutorInner 

Source
pub struct ExecutorInner {
    pub workers: Vec<Arc<Worker>>,
    pub global_queue: Mutex<VecDeque<Arc<Task>>>,
    pub tasks: Mutex<HashMap<TaskId, Arc<Task>>>,
    pub next_task_id: AtomicU64,
    pub running: AtomicBool,
    pub shutdown: AtomicBool,
    pub park_condvar: Condvar,
    pub park_mutex: Mutex<()>,
    pub active_workers: AtomicUsize,
}
Expand description

Shared executor state.

Fields§

§workers: Vec<Arc<Worker>>

All workers.

§global_queue: Mutex<VecDeque<Arc<Task>>>

Global task queue for overflow/new tasks.

§tasks: Mutex<HashMap<TaskId, Arc<Task>>>

All tasks by ID.

§next_task_id: AtomicU64

Next task ID.

§running: AtomicBool

Is the executor running?

§shutdown: AtomicBool

Shutdown signal.

§park_condvar: Condvar

Condition variable for parking workers.

§park_mutex: Mutex<()>

Mutex for parking.

§active_workers: AtomicUsize

Number of active (non-parked) workers.

Implementations§

Source§

impl ExecutorInner

Source

pub fn wake_task(&self, task_id: TaskId)

Wake a task by ID, moving it to ready state and scheduling it.

Source

pub fn alloc_task_id(&self) -> TaskId

Allocate a new task ID.

Source

pub fn get_task(&self, task_id: TaskId) -> Option<Arc<Task>>

Get task by ID.

Source

pub fn unpark_workers(&self)

Unpark workers.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.