File tree Expand file tree Collapse file tree 3 files changed +29
-17
lines changed
FsToolkit.ErrorHandling.IcedTasks
FsToolkit.ErrorHandling.TaskResult Expand file tree Collapse file tree 3 files changed +29
-17
lines changed Original file line number Diff line number Diff line change @@ -105,17 +105,22 @@ module CancellableTaskResultCE =
105105 [<InlineIfLambda>] condition : unit -> bool ,
106106 body : CancellableTaskResultCode < 'TOverall , 'Error , unit >
107107 ) : CancellableTaskResultCode < 'TOverall , 'Error , unit > =
108+ let mutable keepGoing = true
109+
108110 ResumableCode.While(
109- condition,
111+ ( fun () ->
112+ keepGoing
113+ && condition ()
114+ ),
110115 CancellableTaskResultCode<_, _, _>( fun sm ->
111116 sm.Data.ThrowIfCancellationRequested()
112- let __stack_body_fin = body.Invoke(& sm)
113117
114118 if sm.Data.IsResultError then
119+ keepGoing <- false
115120 sm.Data.MethodBuilder.SetResult sm.Data.Result
116- false
121+ true
117122 else
118- __ stack _ body _ fin
123+ body.Invoke (& sm )
119124 )
120125 )
121126
Original file line number Diff line number Diff line change @@ -519,16 +519,20 @@ type TaskOptionBuilderBase() =
519519 [<InlineIfLambda>] condition : unit -> bool ,
520520 body : TaskOptionCode < 'TOverall , unit >
521521 ) : TaskOptionCode < 'TOverall , unit > =
522+ let mutable keepGoing = true
523+
522524 ResumableCode.While(
523- condition,
525+ ( fun () ->
526+ keepGoing
527+ && condition ()
528+ ),
524529 TaskOptionCode<_, _>( fun sm ->
525- let __stack_body_fin = body.Invoke(& sm)
526-
527530 if sm.Data.IsResultNone then
531+ keepGoing <- false
528532 sm.Data.SetResult()
529- false
533+ true
530534 else
531- __ stack _ body _ fin
535+ body.Invoke (& sm )
532536 )
533537 )
534538
@@ -639,9 +643,8 @@ type TaskOptionBuilderBase() =
639643
640644 member inline this.Source ( taskOption : TaskOption < 'T >) : TaskOption < 'T > = taskOption
641645
642- member inline this.Source ( taskOption : ValueTask < 'T option >) : TaskOption < 'T > = task {
643- return ! taskOption
644- }
646+ member inline this.Source ( taskOption : ValueTask < 'T option >) : TaskOption < 'T > =
647+ taskOption.AsTask()
645648
646649
647650type TaskOptionBuilder () =
Original file line number Diff line number Diff line change @@ -564,16 +564,20 @@ type TaskResultBuilderBase() =
564564 [<InlineIfLambda>] condition : unit -> bool ,
565565 body : TaskResultCode < 'TOverall , 'Error , unit >
566566 ) : TaskResultCode < 'TOverall , 'Error , unit > =
567+ let mutable keepGoing = true
568+
567569 ResumableCode.While(
568- condition,
570+ ( fun () ->
571+ keepGoing
572+ && condition ()
573+ ),
569574 TaskResultCode<_, _, _>( fun sm ->
570- let __stack_body_fin = body.Invoke(& sm)
571-
572575 if sm.Data.IsResultError then
576+ keepGoing <- false
573577 sm.Data.MethodBuilder.SetResult sm.Data.Result
574- false
578+ true
575579 else
576- __ stack _ body _ fin
580+ body.Invoke (& sm )
577581 )
578582 )
579583
You can’t perform that action at this time.
0 commit comments