|
1 | 1 | # AsyncChannelKit
|
2 | 2 |
|
3 |
| -A simple implementation of an async channel for use with [AsyncSequence] and [AsyncIterator]. |
| 3 | +A simple implementation of an async channel for use with [AsyncSequence] and [AsyncIterator] which matches |
| 4 | +the same interface as [Channel]. |
4 | 5 |
|
5 |
| -When the `next()` function is called it is expected to return a value asynchronusly for an async for loop. |
| 6 | +When the `next()` function is called it is expected to return a value asynchronusly for an async `for` loop. |
6 | 7 | If the values are not created in response to calling this function these values will have to be provided
|
7 | 8 | somehow. This channel supports sending values which the `next()` can return.
|
8 | 9 |
|
9 |
| -In the unit tests, a channel is created and given to the sequence. When the iterator is created it is |
10 |
| -given the same channel. Calling `send` on the channel will make new values available. When the `next` |
11 |
| -function is called it creates a `continuation` which will be matched to a value so it can be returned. |
12 |
| -Calling `terminate` will use a `continuation` to send `nil` which tells the for loop it is done. |
| 10 | +In the unit tests, a channel is created which is also a sequence. The `AyncIterator` is a nested type. |
| 11 | +When the iterator is created it is given the same channel. Calling `send` on the channel will make new |
| 12 | +values available. When the `next` function is called it creates a `continuation` which will be matched |
| 13 | +to a value so it can be returned. Calling `terminate` will use a `continuation` to send `nil` which tells |
| 14 | +the `for` loop it is done. |
13 | 15 |
|
14 |
| -All of the work done by the channel is done as an actor type so that it is thread-safe. |
| 16 | +All of the work done by the channel is done as an actor type so that it is thread-safe. Since it only uses |
| 17 | +features from the Swift Standard Library it should be usable on every platform which has Swift support. |
15 | 18 |
|
16 | 19 | [AsyncSequence]: https://developer.apple.com/documentation/swift/asyncsequence
|
17 | 20 | [AsyncIterator]: https://developer.apple.com/documentation/swift/asyncsequence/asynciterator
|
| 21 | +[Channel]: https://github.com/apple/swift-async-algorithms/blob/main/Sources/AsyncAlgorithms/AsyncAlgorithms.docc/Guides/Channel.md |
0 commit comments