arty 0.6.0

Thread-aware async runtime that keeps each task on one worker thread.
Documentation
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

use arty::runtime::{Runtime, RuntimeControl};
use arty::task::{JoinError, JoinHandle};

pub(crate) fn runtime_control(runtime: &Runtime) -> RuntimeControl {
    runtime
        .scheduler()
        .block_on(async |cx| cx.control().clone())
        .expect("runtime remains active while acquiring test control")
}

const _: fn(&Runtime) -> RuntimeControl = runtime_control;

pub(crate) trait JoinHandleExt {
    type Output;

    fn join(self) -> Result<Self::Output, JoinError>;
}

impl<R> JoinHandleExt for JoinHandle<R>
where
    R: Send + 'static,
{
    type Output = R;

    fn join(self) -> Result<Self::Output, JoinError> {
        futures::executor::block_on(self)
    }
}

const _: fn(JoinHandle<()>) -> Result<(), JoinError> = <JoinHandle<()> as JoinHandleExt>::join;