feat: allow multi-thread worker with feature flag
This commit is contained in:
parent
df52674e3d
commit
1da003dc28
2 changed files with 14 additions and 1 deletions
|
@ -19,3 +19,4 @@ async-recursion = "1.1.1"
|
|||
[features]
|
||||
default = []
|
||||
bundled = ["rusqlite/bundled"]
|
||||
multi-thread = ["tokio/rt-multi-thread", "tokio/time"]
|
||||
|
|
14
src/main.rs
14
src/main.rs
|
@ -50,7 +50,19 @@ fn main() {
|
|||
},
|
||||
};
|
||||
|
||||
if let Err(e) = tokio::runtime::Builder::new_current_thread()
|
||||
let mut runtime_builder = {
|
||||
#[cfg(feature = "multi-thread")]
|
||||
{
|
||||
tokio::runtime::Builder::new_multi_thread()
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "multi-thread"))]
|
||||
{
|
||||
tokio::runtime::Builder::new_current_thread()
|
||||
}
|
||||
};
|
||||
|
||||
if let Err(e) = runtime_builder
|
||||
.enable_all()
|
||||
.build()
|
||||
.expect("could not create tokio runtime")
|
||||
|
|
Loading…
Reference in a new issue