+
Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions src/yield_now.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ pub fn yield_with<T: EventSource>(resource: &T) {
return resource.yield_back(cancel);
}

let r = resource as &dyn EventSource as *const _ as *mut _;
let r = unsafe {
std::mem::transmute::<*const (dyn EventSource + '_), *mut (dyn EventSource + 'static)>(
resource as &dyn EventSource,
)
};
let es = EventSubscriber::new(r);
co_yield_with(es);

Expand All @@ -45,13 +49,21 @@ pub fn yield_with_io<T: EventSource>(resource: &T, is_coroutine: bool) {
yield_with(resource);
#[cfg(not(feature = "io_cancel"))]
{
let r = resource as &dyn EventSource as *const _ as *mut _;
let r = unsafe {
std::mem::transmute::<*const (dyn EventSource + '_), *mut (dyn EventSource + 'static)>(
resource as &dyn EventSource,
)
};
let es = EventSubscriber::new(r);
co_yield_with(es);
}
} else {
// for thread is only park the thread
let r = resource as &dyn EventSource as *const _ as *mut _;
let r = unsafe {
std::mem::transmute::<*const (dyn EventSource + '_), *mut (dyn EventSource + 'static)>(
resource as &dyn EventSource,
)
};
let es = EventSubscriber::new(r);
crate::io::thread::PROXY_CO_SENDER.with(|tx| {
tx.send(es).unwrap();
Expand Down
Loading
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载