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 @@ -649,6 +649,12 @@ module HighPriority =
649
649
sm.Data.current <- ValueNone
650
650
false )
651
651
652
+ // Binding to a cancellation token. This allows `do! someCancellationToken`
653
+ member inline _.Bind ( myToken : CancellationToken , continuation : ( unit -> ResumableTSC < 'T >)) : ResumableTSC < 'T > =
654
+ ResumableTSC< 'T>( fun sm ->
655
+ sm.Data.cancellationToken <- myToken
656
+ ( continuation ()) .Invoke(& sm))
657
+
652
658
member inline _.Bind ( computation : Async < 'T >, continuation : ( 'T -> ResumableTSC < 'U >)) =
653
659
ResumableTSC< 'U>( fun sm ->
654
660
let mutable awaiter =
Original file line number Diff line number Diff line change @@ -76,6 +76,11 @@ module internal TaskSeqInternal =
76
76
KeyNotFoundException( " The predicate function or index did not satisfy any item in the task sequence." )
77
77
|> raise
78
78
79
+ let inline withCancellationToken ( cancellationToken : CancellationToken ) ( source : taskSeq < 'T >) = taskSeq {
80
+ do ! cancellationToken
81
+ yield ! source
82
+ }
83
+
79
84
let isEmpty ( source : TaskSeq < _ >) =
80
85
checkNonNull ( nameof source) source
81
86
You can’t perform that action at this time.
0 commit comments