pub unsafe fn add_unsafe<'a, F>(&self, f: F)
    where
        F: FnOnce(SubCo) + Send + 'a,
    {
        let id = self.id.fetch_add(1, Ordering::Relaxed);
        let sub = SubCo {
            id,
            co_map: self.co_map.clone(),
        };

        let closure: Box<dyn FnOnce(SubCo) + Send + 'a> = Box::new(f);
        let closure: Box<dyn FnOnce(SubCo) + Send> = std::mem::transmute(closure);

        let co = go!(move || closure(sub));

        // it doesn't' matter if the co is already done here
        // this will just leave any entry in the map and eventually
        // will be dropped after all coroutines done
        self.co_map.insert(id, co);
    }
/// add sub coroutine that not static
///
/// # Safety
///
/// the `SubCo` may not live long enough
add sub coroutine that not static
add sub coroutine that not static
pub unsafe fn add_unsafe<'a, F>(&self, f: F)
    where
        F: FnOnce(SubCo) + Send + 'a,
    {
        let id = self.id.fetch_add(1, Ordering::Relaxed);
        let sub = SubCo {
            id,
            co_map: self.co_map.clone(),
        };
        let closure: Box<dyn FnOnce(SubCo) + Send + 'a> = Box::new(f);
        let closure: Box<dyn FnOnce(SubCo) + Send> = std::mem::transmute(closure);
        let co = go!(move || closure(sub));
        // it doesn't' matter if the co is already done here
        // this will just leave any entry in the map and eventually
        // will be dropped after all coroutines done
        self.co_map.insert(id, co);
    }
pub unsafe fn add_unsafe < ' a , F > ( & self , f : F ) where F : FnOnce ( SubCo ) + Send + ' a , { let id = self . id . fetch_add ( 1 , Ordering :: Relaxed ) ; let sub = SubCo { id , co_map : self . co_map . clone ( ) , } ; let closure : Box < dyn FnOnce ( SubCo ) + Send + ' a > = Box :: new ( f ) ; let closure : Box < dyn FnOnce ( SubCo ) + Send > = std :: mem :: transmute ( closure ) ; let co = go ! ( move closure ( sub ) ) ; // it doesn't' matter if the co is already done here // this will just leave any entry in the map and eventually // will be dropped after all coroutines done self . co_map . insert ( id , co ) ; }
add sub coroutine that not static
add sub coroutine that not static
&self
f
F
&self
f
F
safety
the `SubCo` may not live long enough
the ` SubCo ` may not live long enough