-
Notifications
You must be signed in to change notification settings - Fork 340
Open
Labels
documentationImprovements or additions to documentationImprovements or additions to documentation
Description
As shared here, channels could potentially deadlock if the capacity isn't large enough:
let (s, r) = channel(1);
s.send(1).await;
s.send(2).await; // this will hang indefinitelyInstead we should probably mention that by using future::timeout this can be prevented from hanging indefinitely:
let (s, r) = channel(1);
future::timeout(s.send(1), Duration::from_secs(1).await);
future::timeout(s.send(2), Duration::from_secs(1).await);Perhaps we could even mention in the docs that folks should probably default to something spacious such as 256 or 1024 messages in case of doubt. In general we probably shouldn't assume people have intuition about channels, and nudging them towards some safer default choices (because unlike with unbounded channels they have to choose) wouldn't be a bad idea probably (:
Nemikolh, vitali2y and qdot
Metadata
Metadata
Assignees
Labels
documentationImprovements or additions to documentationImprovements or additions to documentation