Skip to content

Commit 979dfaf

Browse files
committed
Elaborate more on the purpose of slots
1 parent c81d62c commit 979dfaf

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

lighthouse-client/src/lighthouse.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,19 @@ pub struct Lighthouse<S> {
2020
request_id: i32,
2121
}
2222

23+
/// A facility for coordinating asynchronous responses to a request between a
24+
/// requesting task and a receive loop task.
2325
enum Slot<M> {
24-
/// Indicates that messages were received before the request task queried it.
25-
/// Generally set by the receive loop task.
26+
/// Indicates that messages were received before the requesting task
27+
/// registered the slot. **The receive loop** will construct this variant in
28+
/// that case, i.e. store the already received messages in a
29+
/// [`Slot::EarlyMessages`].
2630
EarlyMessages(Vec<M>),
27-
/// Indicates that messages were not received before the request task queried it.
28-
/// Generally set by the request task.
31+
/// Indicates that no messages were received before the requesting task
32+
/// registered the slot. **The requesting thread** will construct this
33+
/// variant in that case, i.e. create a channel, store the sender in a
34+
/// [`Slot::WaitForMessages`] for the receive loop and then return the
35+
/// receiver.
2936
WaitForMessages(Sender<M>),
3037
}
3138

0 commit comments

Comments
 (0)