Skip to content
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

How to shutdown tokio::runtime::current_thread::Runtime? #796

Closed
xxks-kkk opened this issue Dec 12, 2018 · 1 comment
Closed

How to shutdown tokio::runtime::current_thread::Runtime? #796

xxks-kkk opened this issue Dec 12, 2018 · 1 comment

Comments

@xxks-kkk
Copy link

xxks-kkk commented Dec 12, 2018

Version

tokio = { version = "0.1.13", features = ["async-await-preview"]}

Platform

Ubuntu 16.04

Description

I'm wondering how can I terminate tokio::runtime::current_thread::Runtime? I'm using the following macro to run some future:

#[macro_export]
macro_rules! block_on_async {
    ($test:expr) => {{
        use tokio::runtime::current_thread::Runtime;
        use tokio_async_await::compat::backward;
        use futures::future;
        use tokio::runtime::current_thread::block_on_all;

        let future = backward::Compat::new(async {
            let _ = await!($test);
            let result: std::result::Result<(), ()> = Ok(());
            result
        });

        let mut rt = Runtime::new().expect("Unable to start async tester runtime");
        rt.block_on(future).unwrap();
    }};
}

After that, I would terminate the reactor. Is there any way I can do that?

@carllerche
Copy link
Member

Dropping rt should perform all necessary shutdown work. Was there anything else you were thinking of that would need to be done?

@xxks-kkk xxks-kkk closed this as completed Jan 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants