| 1 | Title: Channels |
| 2 | |
| 3 | # Overview |
| 4 | |
| 5 | [[email protected]] provides a producer consumer queue for applications. |
| 6 | The channel has a read and a write side that allows you to put futures into the queue. |
| 7 | Futures are used because they provide a convenient container that is used elsewhere in the library. |
| 8 | |
| 9 | A common use of channels is to dispatch work to a worker fiber. |
| 10 | |
| 11 | You can close the read or the write side independently which will cause the other side to be notified if waiting on a future. |
| 12 | |
| 13 | Use [[email protected]_receive] to close the read side of the channel. |
| 14 | You should do this when stopping a worker fiber so that producers are notified that submitting items into the channel has failed. |
| 15 | |
| 16 | Use [[email protected]_send] to close the write side of the channel. |
| 17 | This allows consumers to receive notification through the form of a rejection that reading from the channel will no longer succeed. |