-
For example, there is a stream API: #[tokio::main(flavor = "current_thread")]
pub async fn call_stream(
path: String,
listener: StreamSink<String>,
) -> anyhow::Result<()> {
Loop{
...
}
} Then, if this API is called multiple times, say 2 times, does it mean that there are 2 independent threads running backstage? Since I need multiple streams, but with the same routines of different parameters, I wonder if I need to create the same API multiple times. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
If you are using default executor I guess it is a thread pool. So if that loop does not terminate it does occupy one thread per function call. But since you are using async I am not sure. Maybe make a simple experiment: |
Beta Was this translation helpful? Give feedback.
If you are using default executor I guess it is a thread pool. So if that loop does not terminate it does occupy one thread per function call.
But since you are using async I am not sure.
Maybe make a simple experiment:
println!
current thread name inside that loop etc.