You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the Async in Depth documentation, this part
doesn't compile:
structTask{// The `Mutex` is to make `Task` implement `Sync`. Only// one thread accesses `future` at any given time. The// `Mutex` is not required for correctness. Real Tokio// does not use a mutex here, but real Tokio has// more lines of code than can fit in a single tutorial// page.future:Mutex<Pin<Box<dynFuture<Output = ()> + Send>>>,executor: mpsc::Sender<Arc<Task>>,}
For what I understand, it is because of ArcWake needs Task to be Sync, and mpsc::Sender is only Send, not Sync.
I found a quick workaround with wrapping the Sender in a Mutex so all members of Task are Sync.
I can submit a two liners PR if you fancy.
The text was updated successfully, but these errors were encountered:
Description
In the Async in Depth documentation, this part
doesn't compile:
For what I understand, it is because of
ArcWake
needsTask
to beSync
, andmpsc::Sender
is onlySend
, notSync
.I found a quick workaround with wrapping the
Sender
in aMutex
so all members ofTask
areSync
.I can submit a two liners PR if you fancy.
The text was updated successfully, but these errors were encountered: