Skip to content

Commit f2eae40

Browse files
committed
Removed commented out code from legacy v4 functions
1 parent edc9ae0 commit f2eae40

File tree

4 files changed

+1
-661
lines changed

4 files changed

+1
-661
lines changed

src/FsToolkit.ErrorHandling.IcedTasks/CancellableTaskOption.fs

Lines changed: 0 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -232,10 +232,6 @@ type ValueTaskValueOptionBuilderBase() =
232232
: CancellableValueTaskValueOption<'T> =
233233
taskOption
234234

235-
// member inline this.Source(taskOption: ValueTask<'T option>) : CancellableTaskOption<'T> =
236-
// taskOption.AsTask()
237-
238-
239235
type ValueTaskValueOptionBuilder() =
240236

241237
inherit ValueTaskValueOptionBuilderBase()
@@ -355,76 +351,6 @@ type TaskOptionBuilder() =
355351
return ValueOption.toOption r
356352
}
357353

358-
359-
// type BackgroundTaskOptionBuilder() =
360-
361-
// inherit TaskOptionBuilderBase()
362-
363-
// static member RunDynamic(code: TaskOptionCode<'T, 'T>) : CancellableTaskOption<'T> =
364-
// // backgroundTask { .. } escapes to a background thread where necessary
365-
// // See spec of ConfigureAwait(false) at https://devblogs.microsoft.com/dotnet/configureawait-faq/
366-
// if
367-
// isNull SynchronizationContext.Current
368-
// && obj.ReferenceEquals(TaskScheduler.Current, TaskScheduler.Default)
369-
// then
370-
// TaskOptionBuilder.RunDynamic(code)
371-
// else
372-
// Task.Run<'T option>(fun () -> TaskOptionBuilder.RunDynamic(code))
373-
374-
375-
// //// Same as TaskBuilder.Run except the start is inside Task.Run if necessary
376-
// member inline _.Run(code: TaskOptionCode<'T, 'T>) : CancellableTaskOption<'T> =
377-
// if __useResumableCode then
378-
// __stateMachine<TaskOptionStateMachineData<'T>, CancellableTaskOption<'T>>
379-
// (MoveNextMethodImpl<_>(fun sm ->
380-
// //-- RESUMABLE CODE START
381-
// __resumeAt sm.ResumptionPoint
382-
383-
// try
384-
// let __stack_code_fin = code.Invoke(&sm)
385-
386-
// if
387-
// __stack_code_fin
388-
// && not sm.Data.IsTaskCompleted
389-
// then
390-
// sm.Data.MethodBuilder.SetResult(sm.Data.Result.Value)
391-
// with exn ->
392-
// sm.Data.MethodBuilder.SetException exn
393-
// //-- RESUMABLE CODE END
394-
// ))
395-
// (SetStateMachineMethodImpl<_>(fun sm state ->
396-
// sm.Data.MethodBuilder.SetStateMachine(state)
397-
// ))
398-
// (AfterCode<_, CancellableTaskOption<'T>>(fun sm ->
399-
// // backgroundTask { .. } escapes to a background thread where necessary
400-
// // See spec of ConfigureAwait(false) at https://devblogs.microsoft.com/dotnet/configureawait-faq/
401-
// if
402-
// isNull SynchronizationContext.Current
403-
// && obj.ReferenceEquals(TaskScheduler.Current, TaskScheduler.Default)
404-
// then
405-
// sm.Data.MethodBuilder <- AsyncTaskOptionMethodBuilder<'T>.Create()
406-
// sm.Data.MethodBuilder.Start(&sm)
407-
// sm.Data.MethodBuilder.Task
408-
// else
409-
// let sm = sm // copy contents of state machine so we can capture it
410-
411-
// Task.Run<'T option>(fun () ->
412-
// let mutable sm = sm // host local mutable copy of contents of state machine on this thread pool thread
413-
// sm.Data.MethodBuilder <- AsyncTaskOptionMethodBuilder<'T>.Create()
414-
// sm.Data.MethodBuilder.Start(&sm)
415-
// sm.Data.MethodBuilder.Task
416-
// )
417-
// ))
418-
// else
419-
// BackgroundTaskOptionBuilder.RunDynamic(code)
420-
421-
// [<AutoOpen>]
422-
// module TaskOptionBuilder =
423-
424-
// let taskOption = ValueTaskValueOptionBuilder()
425-
// let backgroundTaskOption = BackgroundTaskOptionBuilder()
426-
427-
428354
[<AutoOpen>]
429355
module TaskOptionCEExtensionsLowPriority =
430356
// Low priority extensions
@@ -626,36 +552,3 @@ module TaskOptionCEExtensionsHighPriority =
626552
this.Bind(task, (fun v -> this.Return v))
627553

628554
member inline _.Source(s: #seq<_>) = s
629-
630-
// [<AutoOpen>]
631-
// module TaskOptionCEExtensionsMediumPriority =
632-
633-
// // Medium priority extensions
634-
// type TaskOptionBuilderBase with
635-
636-
// member inline this.Source(t: Task<'T>) : CancellableTaskOption<'T> =
637-
// t
638-
// |> Task.map Some
639-
640-
// member inline this.Source(t: Task) : CancellableTaskOption<unit> =
641-
// task {
642-
// do! t
643-
// return Some()
644-
// }
645-
646-
// member inline this.Source(t: ValueTask<'T>) : CancellableTaskOption<'T> =
647-
// t
648-
// |> Task.mapV Some
649-
650-
// member inline this.Source(t: ValueTask) : CancellableTaskOption<unit> =
651-
// task {
652-
// do! t
653-
// return Some()
654-
// }
655-
656-
// member inline this.Source(opt: Option<'T>) : CancellableTaskOption<'T> = Task.FromResult opt
657-
658-
// member inline this.Source(computation: Async<'T>) : CancellableTaskOption<'T> =
659-
// computation
660-
// |> Async.map Some
661-
// |> Async.StartImmediateAsTask

src/FsToolkit.ErrorHandling.IcedTasks/CancellableTaskResultBuilderBase.fs

Lines changed: 0 additions & 208 deletions
Original file line numberDiff line numberDiff line change
@@ -648,15 +648,6 @@ module CancellableTaskResultBuilderBase =
648648
continuation = (fun v -> this.Return v)
649649
)
650650

651-
652-
// [<NoEagerConstraintApplication>]
653-
// member inline this.BindReturn
654-
// (
655-
// [<InlineIfLambda>] getAwaiterT: CancellationToken -> 'Awaiter,
656-
// mapper: 'TResult1 -> 'TResult2
657-
// ) : CancellableTaskResultBuilderBaseCode<_, _, _, _> =
658-
// this.Bind((fun ct -> getAwaiterT ct), (fun v -> this.Return(mapper v)))
659-
660651
/// <summary>
661652
/// The entry point for the dynamic implementation of the corresponding operation. Do not use directly, only used when executing quotations that involve tasks or other reflective execution of F# code.
662653
/// </summary>
@@ -761,124 +752,12 @@ module CancellableTaskResultBuilderBase =
761752
: CancellableTaskResultBuilderBaseCode<_, _, _, 'Builder> =
762753
this.Bind(awaiterT = awaiterT, continuation = (fun v -> this.Return v))
763754

764-
// [<NoEagerConstraintApplication>]
765-
// member inline this.BindReturn
766-
// (
767-
// awaiterT: 'Awaiter,
768-
// [<InlineIfLambda>] mapper: 'a -> 'TResult2
769-
// ) : CancellableTaskResultBuilderBaseCode<'TResult2, 'TResult2, 'Error, 'Builder> =
770-
// this.Bind(awaiterT = awaiterT, continuation = (fun v -> this.Return(mapper v)))
771-
772-
773755
/// <exclude/>
774756
[<AutoOpen>]
775757
module LowPriority =
776758
// Low priority extensions
777759
type CancellableTaskResultBuilderBase with
778760

779-
// /// <summary>
780-
// /// The entry point for the dynamic implementation of the corresponding operation. Do not use directly, only used when executing quotations that involve tasks or other reflective execution of F# code.
781-
// /// </summary>
782-
// [<NoEagerConstraintApplication>]
783-
// static member inline BindDynamic
784-
// (
785-
// sm:
786-
// byref<ResumableStateMachine<CancellableTaskResultBuilderBaseStateMachineData<'TOverall, 'Error, 'Builder>>>,
787-
// [<InlineIfLambda>] getAwaiter: CancellationToken -> 'Awaiter,
788-
// continuation:
789-
// ('TResult1
790-
// -> CancellableTaskResultBuilderBaseCode<'TOverall, 'TResult2, 'Error, 'Builder>)
791-
// ) : bool =
792-
// sm.Data.ThrowIfCancellationRequested()
793-
794-
// let mutable awaiter = getAwaiter sm.Data.CancellationToken
795-
796-
// let cont =
797-
// (CancellableTaskResultBuilderBaseResumptionFunc<'TOverall, 'Error, _>(fun sm ->
798-
// let result = Awaiter.GetResult awaiter
799-
800-
// match result with
801-
// | Ok result -> (continuation result).Invoke(&sm)
802-
// | Error e ->
803-
// sm.Data.Result <- Error e
804-
// true
805-
// ))
806-
807-
// // shortcut to continue immediately
808-
// if Awaiter.IsCompleted awaiter then
809-
// cont.Invoke(&sm)
810-
// else
811-
// sm.ResumptionDynamicInfo.ResumptionData <-
812-
// (awaiter :> ICriticalNotifyCompletion)
813-
814-
// sm.ResumptionDynamicInfo.ResumptionFunc <- cont
815-
// false
816-
817-
// /// <summary>Creates A CancellableTask that runs computation, and when
818-
// /// computation generates a result T, runs binder res.</summary>
819-
// ///
820-
// /// <remarks>A cancellation check is performed when the computation is executed.
821-
// ///
822-
// /// The existence of this method permits the use of let! in the
823-
// /// cancellableTask { ... } computation expression syntax.</remarks>
824-
// ///
825-
// /// <param name="getAwaiter">The computation to provide an unbound result.</param>
826-
// /// <param name="continuation">The function to bind the result of computation.</param>
827-
// ///
828-
// /// <returns>A CancellableTask that performs a monadic bind on the result
829-
// /// of computation.</returns>
830-
// [<NoEagerConstraintApplication>]
831-
// member inline _.Bind
832-
// (
833-
// [<InlineIfLambda>] getAwaiterTResult: CancellationToken -> 'Awaiter,
834-
// continuation:
835-
// ('TResult1
836-
// -> CancellableTaskResultBuilderBaseCode<'TOverall, 'TResult2, 'Error, 'Builder>)
837-
// ) : CancellableTaskResultBuilderBaseCode<'TOverall, 'TResult2, 'Error, 'Builder> =
838-
839-
// CancellableTaskResultBuilderBaseCode<'TOverall, 'TResult2, 'Error, 'Builder>(fun sm ->
840-
// if __useResumableCode then
841-
// //-- RESUMABLE CODE START
842-
// sm.Data.ThrowIfCancellationRequested()
843-
// // Get an awaiter from the Awaiter
844-
// let mutable awaiter = getAwaiterTResult sm.Data.CancellationToken
845-
846-
// let mutable __stack_fin = true
847-
848-
// if not (Awaiter.IsCompleted awaiter) then
849-
// // This will yield with __stack_yield_fin = false
850-
// // This will resume with __stack_yield_fin = true
851-
// let __stack_yield_fin = ResumableCode.Yield().Invoke(&sm)
852-
// __stack_fin <- __stack_yield_fin
853-
854-
// if __stack_fin then
855-
// let result = Awaiter.GetResult awaiter
856-
857-
// match result with
858-
// | Ok result -> (continuation result).Invoke(&sm)
859-
// | Error e ->
860-
// sm.Data.Result <- Error e
861-
// true
862-
// else
863-
// let mutable awaiter = awaiter :> ICriticalNotifyCompletion
864-
865-
// MethodBuilder.AwaitUnsafeOnCompleted(
866-
// &sm.Data.MethodBuilder,
867-
// &awaiter,
868-
// &sm
869-
// )
870-
871-
// false
872-
// else
873-
// CancellableTaskResultBuilderBase.BindDynamic(
874-
// &sm,
875-
// getAwaiterTResult,
876-
// continuation
877-
// )
878-
// //-- RESUMABLE CODE END
879-
// )
880-
881-
882761
/// <summary>Delegates to the input computation.</summary>
883762
///
884763
/// <remarks>The existence of this method permits the use of return! in the
@@ -896,16 +775,6 @@ module CancellableTaskResultBuilderBase =
896775
continuation = (fun v -> this.Return v)
897776
)
898777

899-
900-
// [<NoEagerConstraintApplication>]
901-
// member inline this.BindReturn
902-
// (
903-
// [<InlineIfLambda>] getAwaiterTResult: CancellationToken -> 'Awaiter,
904-
// mapper: 'TResult1 -> 'TResult2
905-
// ) : CancellableTaskResultBuilderBaseCode<_, _, _, _> =
906-
// this.Bind((fun ct -> getAwaiterTResult ct), (fun v -> this.Return(mapper v)))
907-
908-
909778
/// <summary>Allows the computation expression to turn other types into CancellationToken -> 'Awaiter</summary>
910779
///
911780
/// <remarks>This turns a CancellationToken -> 'Awaitable into a CancellationToken -> 'Awaiter.</remarks>
@@ -1060,18 +929,6 @@ module CancellableTaskResultBuilderBase =
1060929
: CancellableTaskResultBuilderBaseCode<_, _, _, 'Builder> =
1061930
this.Bind(awaiterTResult = awaiterTResult, continuation = (fun v -> this.Return v))
1062931

1063-
// [<NoEagerConstraintApplication>]
1064-
// member inline this.BindReturn
1065-
// (
1066-
// awaiterTResult: 'Awaiter,
1067-
// [<InlineIfLambda>] mapper: 'a -> 'TResult2
1068-
// ) : CancellableTaskResultBuilderBaseCode<'TResult2, 'TResult2, 'Error, 'Builder> =
1069-
// this.Bind(
1070-
// awaiterTResult = awaiterTResult,
1071-
// continuation = (fun v -> this.Return(mapper v))
1072-
// )
1073-
1074-
1075932
/// <summary>Allows the computation expression to turn other types into CancellationToken -> 'Awaiter</summary>
1076933
///
1077934
/// <remarks>This is the identify function.</remarks>
@@ -1213,71 +1070,6 @@ module CancellableTaskResultBuilderBase =
12131070
: Async<_> =
12141071
Async.AwaitCancellableTaskResult t
12151072

1216-
1217-
// type AsyncEx with
1218-
1219-
// /// <summary>Return an asynchronous computation that will wait for the given task to complete and return
1220-
// /// its result.</summary>
1221-
// ///
1222-
// /// <remarks>
1223-
// /// This is based on <see href="https://github.com/fsharp/fslang-suggestions/issues/840">Async.Await overload (esp. AwaitTask without throwing AggregateException)</see>
1224-
// /// </remarks>
1225-
// static member inline AwaitCancellableTask
1226-
// ([<InlineIfLambda>] t: CancellationToken -> Task<'T>)
1227-
// =
1228-
// asyncEx {
1229-
// let! ct = Async.CancellationToken
1230-
// return! t ct
1231-
// }
1232-
1233-
// /// <summary>Return an asynchronous computation that will wait for the given task to complete and return
1234-
// /// its result.</summary>
1235-
// ///
1236-
// /// <remarks>
1237-
// /// This is based on <see href="https://github.com/fsharp/fslang-suggestions/issues/840">Async.Await overload (esp. AwaitTask without throwing AggregateException)</see>
1238-
// /// </remarks>
1239-
// static member inline AwaitCancellableTask
1240-
// ([<InlineIfLambda>] t: CancellationToken -> Task)
1241-
// =
1242-
// asyncEx {
1243-
// let! ct = Async.CancellationToken
1244-
// return! t ct
1245-
// }
1246-
1247-
// type Microsoft.FSharp.Control.Async with
1248-
1249-
// /// <summary>Return an asynchronous computation that will wait for the given task to complete and return
1250-
// /// its result.</summary>
1251-
// static member inline AwaitCancellableTask
1252-
// ([<InlineIfLambda>] t: CancellationToken -> Task<'T>)
1253-
// =
1254-
// async {
1255-
// let! ct = Async.CancellationToken
1256-
1257-
// return!
1258-
// t ct
1259-
// |> Async.AwaitTask
1260-
// }
1261-
1262-
// /// <summary>Return an asynchronous computation that will wait for the given task to complete and return
1263-
// /// its result.</summary>
1264-
// static member inline AwaitCancellableTask
1265-
// ([<InlineIfLambda>] t: CancellationToken -> Task)
1266-
// =
1267-
// async {
1268-
// let! ct = Async.CancellationToken
1269-
1270-
// return!
1271-
// t ct
1272-
// |> Async.AwaitTask
1273-
// }
1274-
1275-
// /// <summary>Runs an asynchronous computation, starting on the current operating system thread.</summary>
1276-
// static member inline AsCancellableTask
1277-
// (computation: Async<'T>)
1278-
// : CancellationToken -> Task<_> =
1279-
// fun ct -> Async.StartImmediateAsTask(computation, cancellationToken = ct)
1280-
12811073
// High priority extensions
12821074
type CancellableTaskResultBuilderBase with
12831075

0 commit comments

Comments
 (0)