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 =
649649 sm.Data.current <- ValueNone
650650 false )
651651
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+
652658 member inline _.Bind ( computation : Async < 'T >, continuation : ( 'T -> ResumableTSC < 'U >)) =
653659 ResumableTSC< 'U>( fun sm ->
654660 let mutable awaiter =
Original file line number Diff line number Diff line change @@ -76,6 +76,11 @@ module internal TaskSeqInternal =
7676 KeyNotFoundException( " The predicate function or index did not satisfy any item in the task sequence." )
7777 |> raise
7878
79+ let inline withCancellationToken ( cancellationToken : CancellationToken ) ( source : taskSeq < 'T >) = taskSeq {
80+ do ! cancellationToken
81+ yield ! source
82+ }
83+
7984 let isEmpty ( source : TaskSeq < _ >) =
8085 checkNonNull ( nameof source) source
8186
You can’t perform that action at this time.
0 commit comments