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 @@ -644,6 +644,12 @@ module HighPriority =
644644 sm.Data.current <- ValueNone
645645 false )
646646
647+ // Binding to a cancellation token. This allows `do! someCancellationToken`
648+ member inline _.Bind ( myToken : CancellationToken , continuation : ( unit -> ResumableTSC < 'T >)) : ResumableTSC < 'T > =
649+ ResumableTSC< 'T>( fun sm ->
650+ sm.Data.cancellationToken <- myToken
651+ ( continuation ()) .Invoke(& sm))
652+
647653 member inline _.Bind ( computation : Async < 'T >, continuation : ( 'T -> ResumableTSC < 'U >)) =
648654 ResumableTSC< 'U>( fun sm ->
649655 let mutable awaiter =
Original file line number Diff line number Diff line change @@ -67,6 +67,11 @@ module internal TaskSeqInternal =
6767 KeyNotFoundException( " The predicate function or index did not satisfy any item in the async sequence." )
6868 |> raise
6969
70+ let inline withCancellationToken ( cancellationToken : CancellationToken ) ( source : taskSeq < 'T >) = taskSeq {
71+ do ! cancellationToken
72+ yield ! source
73+ }
74+
7075 let isEmpty ( source : TaskSeq < _ >) =
7176 checkNonNull ( nameof source) source
7277
You can’t perform that action at this time.
0 commit comments