You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
461 B
18 lines
461 B
3 years ago
|
pub mod agent;
|
||
2 years ago
|
pub mod connections;
|
||
|
pub mod env;
|
||
|
|
||
|
use std::future::Future;
|
||
1 year ago
|
use std::thread;
|
||
|
use tokio::runtime::Runtime;
|
||
2 years ago
|
|
||
1 year ago
|
// tokio runtime cannot be created inside another runtime,
|
||
|
// so i create a separate non-'static thread not to interfere
|
||
|
fn run_async<R: Send>(fut: impl Future<Output = R> + Send) -> R {
|
||
|
thread::scope(|s| {
|
||
|
s.spawn(|| Runtime::new().unwrap().block_on(fut))
|
||
|
.join()
|
||
|
.expect("async task failed")
|
||
|
})
|
||
2 years ago
|
}
|