tokio 쓰는데요, tokio::spawn 하는 순간 이 에러가 터집니다. 컴파일러 에러 메시지가 너무 길고 어려워서 며칠째 헤매는 중이에요.
error: future cannot be sent between threads safely
--> src/handler.rs:42:5
|
42 | tokio::spawn(async move {
| ^^^^^^^^^^^^ future created by async block is not `Send`
|
= help: the trait `Send` is not implemented for
`std::sync::MutexGuard<'_, State>`
note: future is not `Send` as this value is used across an await
--> src/handler.rs:47:31
|
45 | let guard = state.lock().unwrap();
46 | let id = guard.next_id();
47 | let res = fetch(id).await;
| ^^^^^ await occurs here, with `guard` still livelock 잡고 값 하나 꺼내서 쓰는 것뿐인데 왜 Send가 안 된다는 건지... 락을 없앨 수도 없고 미치겠습니다. 어떻게 해결하나요?
댓글 0