fbinit_tokio/lib.rs
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under both the MIT license found in the
5 * LICENSE-MIT file in the root directory of this source tree and the Apache
6 * License, Version 2.0 found in the LICENSE-APACHE file in the root directory
7 * of this source tree.
8 */
9
10use std::future::Future;
11
12pub fn tokio_test<F>(f: F) -> <F as Future>::Output
13where
14 F: Future,
15{
16 tokio::runtime::Builder::new_current_thread()
17 .enable_all()
18 .build()
19 .unwrap()
20 .block_on(f)
21}
22
23pub fn tokio_main<F>(f: F) -> <F as Future>::Output
24where
25 F: Future,
26{
27 tokio::runtime::Builder::new_multi_thread()
28 .enable_all()
29 .build()
30 .unwrap()
31 .block_on(f)
32}