@@ -158,8 +158,10 @@ the GUI thread.
158
158
159
159
method wait(Supply:D:)
160
160
161
- Waits until the supply is done (in which case it returns C < True > ) or C < quit >
162
- (in which case it will throw the exception that was passed to C < quit > ).
161
+ Taps the C < Supply > it is called on, and blocks execution until the either the supply
162
+ is C < done > (in which case it evaluates to the final value that was emitted on the
163
+ C < Supply > , or C < Nil > if not value was emitted) or C < quit > (in which case it will throw
164
+ the exception that was passed to C < quit > ).
163
165
164
166
my $s = Supplier.new;
165
167
start {
@@ -176,16 +178,19 @@ Waits until the supply is done (in which case it returns C<True>) or C<quit>
176
178
177
179
method list(Supply:D: --> List:D)
178
180
179
- Waits until the supply is done, then returns a list of all values emitted
180
- since the C < list > call.
181
+ Taps the C < Supply > it is called on, and returns a lazy list that will be reified
182
+ as the C < Supply > emits values. The list will be terminated once the C < Supply > is
183
+ C < done > . If the C < Supply > C < quit > s, then an exception will be thrown once that
184
+ point in the lazy list is reached.
181
185
182
186
= head2 method grab
183
187
184
188
method grab(Supply:D: &when-done --> Supply:D)
185
189
186
- Waits until the given C < Supply > is done. It will then call the C < &when-done >
187
- closure passing all of the values seen, Then creates a C < Supply > to which all
188
- values returned from the C < &when-done > closure are emitted.
190
+ Taps the C < Supply > it is called on. When it is C < done > , calls C < &when-done > and
191
+ then emits the list of values that it returns on the result C < Supply > . If the
192
+ original C < Supply > C < quit > s, then the exception is immediately conveyed on the
193
+ return C < Supply > .
189
194
190
195
my $s = Supply.from-list(4, 10, 3, 2);
191
196
my $t = $s.grab(&sum);
@@ -195,8 +200,10 @@ values returned from the C<&when-done> closure are emitted.
195
200
196
201
method reverse(Supply:D: --> Supply:D)
197
202
198
- Waits until the given C < Supply > is done, then creates a C < Supply > to which all
199
- values seen are emitted in reverse order.
203
+ Taps the C < Supply > it is called on. Once that C < Supply > emits C < done > , all of the
204
+ values it emitted will be emitted on the returned C < Supply > in reverse order. If
205
+ the original C < Supply > C < quit > s, then the exception is immediately conveyed on the
206
+ return C < Supply > .
200
207
201
208
my $s = Supply.from-list(1, 2, 3);
202
209
my $t = $s.reverse;
@@ -206,9 +213,11 @@ values seen are emitted in reverse order.
206
213
207
214
method sort(Supply:D: &custom-routine-to-use? --> Supply:D)
208
215
209
- Waits until the given C < Supply > is done, then creates a C < Supply > to which all
210
- values seen are emitted in sorted order. Optionally accepts a comparator
211
- L < Block|/type/Block > .
216
+ Taps the C < Supply > it is called on. Once that C < Supply > emits C < done > , all of the
217
+ values that it emitted will be sorted, and the results emitted on the returned
218
+ C < Supply > in the sorted order. Optionally accepts a comparator L < Block|/type/Block > .
219
+ If the original C < Supply > C < quit > s, then the exception is immediately conveyed on the
220
+ return C < Supply > .
212
221
213
222
my $s = Supply.from-list(4, 10, 3, 2);
214
223
my $t = $s.sort();
0 commit comments