-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ask for bringing back the std::rt::unwind::try
#28726
Comments
Check out Maybe you want to participate in the discussion around it too, it's ongoing: rust-lang/rfcs/pull/1236 |
I don't think |
|
Yes, please comment on that RFC! And if there's some reason it doesn't work, adding yet another catching mechanism, like that one, would need an RFC anyway, so I'm going to give this issue a close. Thank you! |
As @bluss mentioned, If you'd like to get the same functionality as before, you can build the old #![feature(catch_panic)]
use std::thread;
pub unsafe fn try<R, F: FnOnce() -> R>(f: F) -> thread::Result<R> {
let mut f = Some(f);
let f = &mut f as *mut Option<F> as usize;
thread::catch_panic(move || {
(*(f as *mut Option<F>)).take().unwrap()()
})
} |
@alexcrichton Thanks Alex! |
Since Rust does not have officially support coroutines, so I attempted to made several crates that supports coroutine scheduling and non-blocking I/O.
But these crates requires
std::rt::unwind::try
to catch panics inside coroutines to prevent worker thread to panicking and exiting. But since the latest nightly version of Rust have madestd::rt
to be private, there won't be another way to catch panics ...So I am here to ask for suggestions:
std::rt
again?yield
keyword) is done, is it possible to letcoio-rs
to go into thestd
crate? Just like thelibgreen
before0.12-dev
. :)By the way,
coroutine-rs
also needs thestd::rt::unwind::begin_unwind
to explicitly start unwinding for preventing memory leaks.The text was updated successfully, but these errors were encountered: