Struct SingleTaskPool

Source
pub struct SingleTaskPool<O: Default + 'static> { /* private fields */ }
Expand description

单线程任务池

Implementations§

Source§

impl<O: Default + 'static> SingleTaskPool<O>

Source

pub fn new(weights: [u8; 2]) -> Self

构建指定权重的单线程任务池

Trait Implementations§

Source§

impl<O: Default + 'static> AsyncTaskPool<O> for SingleTaskPool<O>

Source§

type Pool = SingleTaskPool<O>

Source§

fn get_thread_id(&self) -> usize

获取绑定的线程唯一id
Source§

fn len(&self) -> usize

获取当前异步任务池内任务数量
Source§

fn push(&self, task: Arc<AsyncTask<Self::Pool, O>>) -> Result<()>

将异步任务加入异步任务池
Source§

fn push_local(&self, task: Arc<AsyncTask<Self::Pool, O>>) -> Result<()>

将异步任务加入本地异步任务池
Source§

fn push_priority( &self, priority: usize, task: Arc<AsyncTask<Self::Pool, O>>, ) -> Result<()>

将指定了优先级的异步任务加入任务池
Source§

fn push_keep(&self, task: Arc<AsyncTask<Self::Pool, O>>) -> Result<()>

异步任务被唤醒时,将异步任务继续加入异步任务池
Source§

fn try_pop(&self) -> Option<Arc<AsyncTask<Self::Pool, O>>>

尝试从异步任务池中弹出一个异步任务
Source§

fn try_pop_all(&self) -> IntoIter<Arc<AsyncTask<Self::Pool, O>>>

尝试从异步任务池中弹出所有异步任务
Source§

fn get_thread_waker(&self) -> Option<&Arc<(AtomicBool, Mutex<()>, Condvar)>>

获取本地线程的唤醒器
Source§

impl<O: Default + 'static> AsyncTaskPoolExt<O> for SingleTaskPool<O>

Source§

fn set_thread_waker( &mut self, thread_waker: Arc<(AtomicBool, Mutex<()>, Condvar)>, )

设置当前绑定本地线程的唤醒器
Source§

fn set_waits( &mut self, _waits: Arc<ArrayQueue<Arc<(AtomicBool, Mutex<()>, Condvar)>>>, )

设置待唤醒的工作者唤醒器队列
Source§

fn get_waits( &self, ) -> Option<&Arc<ArrayQueue<Arc<(AtomicBool, Mutex<()>, Condvar)>>>>

获取待唤醒的工作者唤醒器队列
Source§

fn idler_len(&self) -> usize

获取空闲的工作者的数量,这个数量大于0,表示可以新开线程来运行可分派的工作者
Source§

fn spawn_worker(&self) -> Option<usize>

分派一个空闲的工作者
Source§

fn worker_len(&self) -> usize

获取工作者的数量
Source§

fn buffer_len(&self) -> usize

获取缓冲区的任务数量,缓冲区任务是未分配给工作者的任务
Source§

fn clone_thread_waker(&self) -> Option<Arc<(AtomicBool, Mutex<()>, Condvar)>>

复制当前绑定本地线程的唤醒器
Source§

fn close_worker(&self)

关闭当前工作者
Source§

impl<O: Default + 'static> Default for SingleTaskPool<O>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<O: Default + 'static> Send for SingleTaskPool<O>

Source§

impl<O: Default + 'static> Sync for SingleTaskPool<O>

Auto Trait Implementations§

§

impl<O> !Freeze for SingleTaskPool<O>

§

impl<O> !RefUnwindSafe for SingleTaskPool<O>

§

impl<O> Unpin for SingleTaskPool<O>

§

impl<O> !UnwindSafe for SingleTaskPool<O>

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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

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

Source§

fn vzip(self) -> V

Source§

impl<T> ThreadSend for T
where T: Send,

Source§

impl<T> ThreadSync for T
where T: Sync + Send,