pub struct CancelToken { /* private fields */ }Expand description
計算の中断の印。計算(要求)ごとに作って with_cancel で渡し、別のスレッドから CancelToken::cancel で倒す。
印は計算ごとなので、同じプロセスで同時に回っている別の計算は止めない。
CancelToken::child で作った子の印は、親が倒れても倒れたとみなす(serve の要求の中で回す最適化など)
Implementations§
Source§impl CancelToken
impl CancelToken
pub fn new() -> CancelToken
Sourcepub fn child(&self) -> CancelToken
pub fn child(&self) -> CancelToken
子の印: 自分を倒しても親は倒れないが、親が倒れれば子も倒れたとみなす
Sourcepub fn cancel(&self)
pub fn cancel(&self)
この印で回っている計算に、区切りのよい所でやめるよう頼む(check_cancel が Error::Cancelled を返す)
Sourcepub fn is_cancelled(&self) -> bool
pub fn is_cancelled(&self) -> bool
中断を頼まれたか(親の印も見る)
Sourcepub fn same(&self, o: &CancelToken) -> bool
pub fn same(&self, o: &CancelToken) -> bool
同じ印か(写しも同じ印)
Trait Implementations§
Source§impl Clone for CancelToken
impl Clone for CancelToken
Source§fn clone(&self) -> CancelToken
fn clone(&self) -> CancelToken
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for CancelToken
impl Debug for CancelToken
Source§impl Default for CancelToken
impl Default for CancelToken
Source§fn default() -> CancelToken
fn default() -> CancelToken
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for CancelToken
impl RefUnwindSafe for CancelToken
impl Send for CancelToken
impl Sync for CancelToken
impl Unpin for CancelToken
impl UnsafeUnpin for CancelToken
impl UnwindSafe for CancelToken
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more