File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -54,6 +54,31 @@ fn with<F: FnOnce(&BorrowedTask) -> R, R>(f: F) -> R {
54
54
/// the future as notifications arrive, until the future terminates.
55
55
///
56
56
/// This is obtained by the `task::current` function.
57
+ ///
58
+ /// # FAQ
59
+ ///
60
+ /// ### Why does `Task` not implement `Eq` and `Hash`?
61
+ ///
62
+ /// A valid use case for `Task` to implement these two traits has not been
63
+ /// encountered.
64
+ ///
65
+ /// Usually, this question is asked by someone who wants to store a `Task`
66
+ /// instance in a `HashSet`. This seems like an obvious way to implement a
67
+ /// future aware, multi-handle structure; e.g. a multi-producer channel.
68
+ ///
69
+ /// In this case, the idea is that whenever a `start_send` is called on one of
70
+ /// the channel's send handles, if the channel is at capacity, the current task
71
+ /// is stored in a set. Then, when capacity is available, a task is removed from
72
+ /// the set and notified.
73
+ ///
74
+ /// The problem with this strategy is that multiple `Sender` handles can be used
75
+ /// on the same task. In this case, when the second handle is used and the task
76
+ /// is stored in a set, there already is an entry. Then, when the first
77
+ /// handle is dropped, this entry is cleared, resulting in a dead lock.
78
+ ///
79
+ /// See [here](https://github.com/rust-lang-nursery/futures-rs/issues/670) for
80
+ /// more discussion.
81
+ ///
57
82
#[ derive( Clone ) ]
58
83
pub struct Task {
59
84
id : usize ,
You can’t perform that action at this time.
0 commit comments