shed/fbinit/fbinit-tokio-02/lib.rs (31 lines of code) (raw):

/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under both the MIT license found in the * LICENSE-MIT file in the root directory of this source tree and the Apache * License, Version 2.0 found in the LICENSE-APACHE file in the root directory * of this source tree. */ use futures::Future; pub fn tokio_test<F>(f: F) -> <F as Future>::Output where F: Future, { tokio::runtime::Builder::new() .basic_scheduler() .enable_all() .build() .unwrap() .block_on(f) } pub fn tokio_main<F>(f: F) -> <F as Future>::Output where F: Future, { tokio::runtime::Builder::new() .threaded_scheduler() .enable_all() .build() .unwrap() .block_on(f) }