advance-practice/shared-state #827
Replies: 7 comments 29 replies
-
|
Beta Was this translation helpful? Give feedback.
-
有个地方不明白,Futrue 是 Pin住的,为啥还能Send到其他线程呢 |
Beta Was this translation helpful? Give feedback.
-
请问,这个”跨“字应该怎么理解?代码中,db也是给了多个process().await用,我理解这里也应该也是”跨“ |
Beta Was this translation helpful? Give feedback.
-
use std::sync::Mutex;
struct CanIncrement {
mutex: Mutex<i32>,
}
impl CanIncrement {
// 该方法不是 `async`
fn increment(&self) {
let mut lock = self.mutex.lock().unwrap();
*lock += 1;
}
}
async fn increment_and_do_stuff(can_incr: &CanIncrement) {
can_incr.increment();
do_something_async().await;
} 文章中的这个例子可以通过编译,是因为只需要在 |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
反馈一个语句不顺的小问题: |
Beta Was this translation helpful? Give feedback.
-
新人问一下这里为什么不用hashmap包裹锁,例如 |
Beta Was this translation helpful? Give feedback.
-
advance-practice/shared-state
https://course.rs/async-rust/tokio/shared-state.html
Beta Was this translation helpful? Give feedback.
All reactions