[][src]Struct generator::Generator

pub struct Generator<'a, A, T> { /* fields omitted */ }

the generator type

Implementations

impl<'a, A, T> Generator<'a, A, T>[src]

pub unsafe fn from_raw(raw: *mut usize) -> Self[src]

Constructs a Generator from a raw pointer.

Safety

This function is unsafe because improper use may lead to memory problems. For example, a double-free may occur if the function is called twice on the same raw pointer.

pub fn into_raw(g: Generator<'a, A, T>) -> *mut usize[src]

Consumes the Generator, returning a wrapped raw pointer.

pub fn prefetch(&self)[src]

prefetch the generator into cache

pub fn scoped_init<F: FnOnce(Scope<'a, A, T>) -> T + 'a>(&mut self, f: F) where
    T: 'a,
    A: 'a, 
[src]

init a heap based generator with scoped closure

pub fn init_code<F: FnOnce() -> T + 'a>(&mut self, f: F) where
    T: 'a, 
[src]

init a heap based generator

pub fn set_para(&mut self, para: A)[src]

prepare the para that passed into generator before send

pub fn set_local_data(&mut self, data: *mut u8)[src]

set the generator local data

pub fn get_local_data(&self) -> *mut u8[src]

get the generator local data

pub fn get_panic_data(&mut self) -> Option<Box<dyn Any + Send>>[src]

get the generator panic data

pub fn resume(&mut self) -> Option<T>[src]

resume the generator without touch the para you should call set_para before this method

pub fn raw_send(&mut self, para: Option<A>) -> Option<T>[src]

raw_send

pub fn send(&mut self, para: A) -> T[src]

send interface

pub unsafe fn cancel(&mut self)[src]

cancel the generator [TODO: change to safe?] this will trigger a Cancel panic

Safety

it's unsafe that cancel may have side effect when unwind stack all the resources would be dropped before the normal completion

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

is finished

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

get stack total size and used size in word

Trait Implementations

impl<'a, A, T> Debug for Generator<'a, A, T>[src]

impl<'a, T> Iterator for Generator<'a, (), T>[src]

type Item = T

The type of the elements being iterated over.

impl<A, T> Send for Generator<'static, A, T>[src]

Auto Trait Implementations

impl<'a, A, T> !RefUnwindSafe for Generator<'a, A, T>

impl<'a, A, T> !Sync for Generator<'a, A, T>

impl<'a, A, T> Unpin for Generator<'a, A, T>

impl<'a, A, T> !UnwindSafe for Generator<'a, A, T>

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<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

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.