File tree Expand file tree Collapse file tree 2 files changed +11
-0
lines changed
src/FSharp.Control.TaskSeq Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -645,6 +645,12 @@ module HighPriority =
645
645
sm.Data.current <- ValueNone
646
646
false )
647
647
648
+ // Binding to a cancellation token. This allows `do! someCancellationToken`
649
+ member inline _.Bind ( myToken : CancellationToken , continuation : ( unit -> ResumableTSC < 'T >)) : ResumableTSC < 'T > =
650
+ ResumableTSC< 'T>( fun sm ->
651
+ sm.Data.cancellationToken <- myToken
652
+ ( continuation ()) .Invoke(& sm))
653
+
648
654
member inline _.Bind ( computation : Async < 'T >, continuation : ( 'T -> ResumableTSC < 'U >)) =
649
655
ResumableTSC< 'U>( fun sm ->
650
656
let mutable awaiter =
Original file line number Diff line number Diff line change @@ -67,6 +67,11 @@ module internal TaskSeqInternal =
67
67
KeyNotFoundException( " The predicate function or index did not satisfy any item in the async sequence." )
68
68
|> raise
69
69
70
+ let inline withCancellationToken ( cancellationToken : CancellationToken ) ( source : taskSeq < 'T >) = taskSeq {
71
+ do ! cancellationToken
72
+ yield ! source
73
+ }
74
+
70
75
let isEmpty ( source : TaskSeq < _ >) =
71
76
checkNonNull ( nameof source) source
72
77
You can’t perform that action at this time.
0 commit comments