[−][src]Struct blackhole::Blackhole
Blackhole
Usage
You should call ::escape_on_idle()
when done with this.
Be careful when you manually call ::drop()
on a blackhole, or simply let it go out of scope. Because background threads are left
unmanaged. They will keep running until main thread exits. Then they will be cancelled/discarded by the system.
Notes
- Messages printed by background threads are prefixed with
TAG
. - About manager thread: to listen to runner threads' messages, at first,
Receiver::recv_timeout()
was considered. However there is a bug: #39364. So, currentlyReceiver::try_recv()
is being used. After that, it sleeps for 1 millisecond. When above bug is fixed, we'll switch to::recv_timeout()
.
Methods
impl<J> Blackhole<J> where
J: Job,
[src]
J: Job,
pub fn make(active_limit: ActiveLimit, queue_limit: usize) -> Result<Self>
[src]
Makes new instance
Notes
- Active limit and queue limit are declared in different types to help prevent typos.
- An error is returned if either active limit or queue limit is zero.
- Internal vectors used for jobs will be made immediately with capacities of active limit and queue limit.
pub fn throw(&self, job: J) -> Result<Option<J>>
[src]
Throws new job into the blackhole
- If the job is accepted,
None
is returned. - If the job is not accepted, it is returned to you for recovery.
pub unsafe fn escape(self) -> Result<()>
[src]
Escapes the blackhole
Notes
- New jobs and all waiting jobs are discarded.
- Active jobs are left untouched. They will be discarded by system when the program's main thread exits.
pub fn escape_on_idle(self) -> Result<()>
[src]
Trait Implementations
Auto Trait Implementations
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,