Follow up on How to run infinite concurrent and parallel tasks? - #9
If I understand properly now, when using tokio:
let rt = Runtime::new()?;
rt.block_on(server::start_warp_server())
And in warp endpoint having this kind of code:
let get_endpoint = warp::path("endpoint").and(warp::query()).and_then(
move |params: HashMap<String, String>| {
async move {
crate::process_request(params)
.await
.map_err(warp::reject::custom::<error::ServerError>)
}
},
);
process_request will never be executed in a new thread?
If I want to use the multi-threading capability of tokio's rt-multi-thread runtime, I need to spawn on each endpoint? Like this:
let get_endpoint = warp::path("endpoint").and(warp::query()).and_then(
move |params: HashMap<String, String>| {
async move {
tokio::spawn(crate::process_request(params))
.await
.map_err(warp::reject::custom::<error::ServerError>)
}
},
);
Am I right?