Skip to content

Commit a5d96b2

Browse files
[v5] Comment Cleanup (#289)
* Removed commented out code from legacy v4 functions * Reverted changes to CancellableTaskOption since it isn't implemented yet --------- Co-authored-by: Jimmy Byrd <[email protected]>
1 parent 6d15f0e commit a5d96b2

File tree

3 files changed

+1
-553
lines changed

3 files changed

+1
-553
lines changed

src/FsToolkit.ErrorHandling.IcedTasks/CancellableTaskResultBuilderBase.fs

Lines changed: 0 additions & 208 deletions
Original file line numberDiff line numberDiff line change
@@ -697,15 +697,6 @@ module CancellableTaskResultBuilderBase =
697697
continuation = (fun v -> this.Return v)
698698
)
699699

700-
701-
// [<NoEagerConstraintApplication>]
702-
// member inline this.BindReturn
703-
// (
704-
// [<InlineIfLambda>] getAwaiterT: CancellationToken -> 'Awaiter,
705-
// mapper: 'TResult1 -> 'TResult2
706-
// ) : CancellableTaskResultBuilderBaseCode<_, _, _, _> =
707-
// this.Bind((fun ct -> getAwaiterT ct), (fun v -> this.Return(mapper v)))
708-
709700
/// <summary>
710701
/// 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.
711702
/// </summary>
@@ -828,124 +819,12 @@ module CancellableTaskResultBuilderBase =
828819
: CancellableTaskResultBuilderBaseCode<_, _, _, 'Builder> =
829820
this.Bind(awaiterT = awaiterT, continuation = (fun v -> this.Return v))
830821

831-
// [<NoEagerConstraintApplication>]
832-
// member inline this.BindReturn
833-
// (
834-
// awaiterT: 'Awaiter,
835-
// [<InlineIfLambda>] mapper: 'a -> 'TResult2
836-
// ) : CancellableTaskResultBuilderBaseCode<'TResult2, 'TResult2, 'Error, 'Builder> =
837-
// this.Bind(awaiterT = awaiterT, continuation = (fun v -> this.Return(mapper v)))
838-
839-
840822
/// <exclude/>
841823
[<AutoOpen>]
842824
module LowPriority =
843825
// Low priority extensions
844826
type CancellableTaskResultBuilderBase with
845827

846-
// /// <summary>
847-
// /// 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.
848-
// /// </summary>
849-
// [<NoEagerConstraintApplication>]
850-
// static member inline BindDynamic
851-
// (
852-
// sm:
853-
// byref<ResumableStateMachine<CancellableTaskResultBuilderBaseStateMachineData<'TOverall, 'Error, 'Builder>>>,
854-
// [<InlineIfLambda>] getAwaiter: CancellationToken -> 'Awaiter,
855-
// continuation:
856-
// ('TResult1
857-
// -> CancellableTaskResultBuilderBaseCode<'TOverall, 'TResult2, 'Error, 'Builder>)
858-
// ) : bool =
859-
// sm.Data.ThrowIfCancellationRequested()
860-
861-
// let mutable awaiter = getAwaiter sm.Data.CancellationToken
862-
863-
// let cont =
864-
// (CancellableTaskResultBuilderBaseResumptionFunc<'TOverall, 'Error, _>(fun sm ->
865-
// let result = Awaiter.GetResult awaiter
866-
867-
// match result with
868-
// | Ok result -> (continuation result).Invoke(&sm)
869-
// | Error e ->
870-
// sm.Data.Result <- Error e
871-
// true
872-
// ))
873-
874-
// // shortcut to continue immediately
875-
// if Awaiter.IsCompleted awaiter then
876-
// cont.Invoke(&sm)
877-
// else
878-
// sm.ResumptionDynamicInfo.ResumptionData <-
879-
// (awaiter :> ICriticalNotifyCompletion)
880-
881-
// sm.ResumptionDynamicInfo.ResumptionFunc <- cont
882-
// false
883-
884-
// /// <summary>Creates A CancellableTask that runs computation, and when
885-
// /// computation generates a result T, runs binder res.</summary>
886-
// ///
887-
// /// <remarks>A cancellation check is performed when the computation is executed.
888-
// ///
889-
// /// The existence of this method permits the use of let! in the
890-
// /// cancellableTask { ... } computation expression syntax.</remarks>
891-
// ///
892-
// /// <param name="getAwaiter">The computation to provide an unbound result.</param>
893-
// /// <param name="continuation">The function to bind the result of computation.</param>
894-
// ///
895-
// /// <returns>A CancellableTask that performs a monadic bind on the result
896-
// /// of computation.</returns>
897-
// [<NoEagerConstraintApplication>]
898-
// member inline _.Bind
899-
// (
900-
// [<InlineIfLambda>] getAwaiterTResult: CancellationToken -> 'Awaiter,
901-
// continuation:
902-
// ('TResult1
903-
// -> CancellableTaskResultBuilderBaseCode<'TOverall, 'TResult2, 'Error, 'Builder>)
904-
// ) : CancellableTaskResultBuilderBaseCode<'TOverall, 'TResult2, 'Error, 'Builder> =
905-
906-
// CancellableTaskResultBuilderBaseCode<'TOverall, 'TResult2, 'Error, 'Builder>(fun sm ->
907-
// if __useResumableCode then
908-
// //-- RESUMABLE CODE START
909-
// sm.Data.ThrowIfCancellationRequested()
910-
// // Get an awaiter from the Awaiter
911-
// let mutable awaiter = getAwaiterTResult sm.Data.CancellationToken
912-
913-
// let mutable __stack_fin = true
914-
915-
// if not (Awaiter.IsCompleted awaiter) then
916-
// // This will yield with __stack_yield_fin = false
917-
// // This will resume with __stack_yield_fin = true
918-
// let __stack_yield_fin = ResumableCode.Yield().Invoke(&sm)
919-
// __stack_fin <- __stack_yield_fin
920-
921-
// if __stack_fin then
922-
// let result = Awaiter.GetResult awaiter
923-
924-
// match result with
925-
// | Ok result -> (continuation result).Invoke(&sm)
926-
// | Error e ->
927-
// sm.Data.Result <- Error e
928-
// true
929-
// else
930-
// let mutable awaiter = awaiter :> ICriticalNotifyCompletion
931-
932-
// MethodBuilder.AwaitUnsafeOnCompleted(
933-
// &sm.Data.MethodBuilder,
934-
// &awaiter,
935-
// &sm
936-
// )
937-
938-
// false
939-
// else
940-
// CancellableTaskResultBuilderBase.BindDynamic(
941-
// &sm,
942-
// getAwaiterTResult,
943-
// continuation
944-
// )
945-
// //-- RESUMABLE CODE END
946-
// )
947-
948-
949828
/// <summary>Delegates to the input computation.</summary>
950829
///
951830
/// <remarks>The existence of this method permits the use of return! in the
@@ -963,16 +842,6 @@ module CancellableTaskResultBuilderBase =
963842
continuation = (fun v -> this.Return v)
964843
)
965844

966-
967-
// [<NoEagerConstraintApplication>]
968-
// member inline this.BindReturn
969-
// (
970-
// [<InlineIfLambda>] getAwaiterTResult: CancellationToken -> 'Awaiter,
971-
// mapper: 'TResult1 -> 'TResult2
972-
// ) : CancellableTaskResultBuilderBaseCode<_, _, _, _> =
973-
// this.Bind((fun ct -> getAwaiterTResult ct), (fun v -> this.Return(mapper v)))
974-
975-
976845
/// <summary>Allows the computation expression to turn other types into CancellationToken -> 'Awaiter</summary>
977846
///
978847
/// <remarks>This turns a CancellationToken -> 'Awaitable into a CancellationToken -> 'Awaiter.</remarks>
@@ -1145,18 +1014,6 @@ module CancellableTaskResultBuilderBase =
11451014
: CancellableTaskResultBuilderBaseCode<_, _, _, 'Builder> =
11461015
this.Bind(awaiterTResult = awaiterTResult, continuation = (fun v -> this.Return v))
11471016

1148-
// [<NoEagerConstraintApplication>]
1149-
// member inline this.BindReturn
1150-
// (
1151-
// awaiterTResult: 'Awaiter,
1152-
// [<InlineIfLambda>] mapper: 'a -> 'TResult2
1153-
// ) : CancellableTaskResultBuilderBaseCode<'TResult2, 'TResult2, 'Error, 'Builder> =
1154-
// this.Bind(
1155-
// awaiterTResult = awaiterTResult,
1156-
// continuation = (fun v -> this.Return(mapper v))
1157-
// )
1158-
1159-
11601017
/// <summary>Allows the computation expression to turn other types into CancellationToken -> 'Awaiter</summary>
11611018
///
11621019
/// <remarks>This is the identify function.</remarks>
@@ -1298,71 +1155,6 @@ module CancellableTaskResultBuilderBase =
12981155
: Async<_> =
12991156
Async.AwaitCancellableTaskResult t
13001157

1301-
1302-
// type AsyncEx with
1303-
1304-
// /// <summary>Return an asynchronous computation that will wait for the given task to complete and return
1305-
// /// its result.</summary>
1306-
// ///
1307-
// /// <remarks>
1308-
// /// This is based on <see href="https://github.com/fsharp/fslang-suggestions/issues/840">Async.Await overload (esp. AwaitTask without throwing AggregateException)</see>
1309-
// /// </remarks>
1310-
// static member inline AwaitCancellableTask
1311-
// ([<InlineIfLambda>] t: CancellationToken -> Task<'T>)
1312-
// =
1313-
// asyncEx {
1314-
// let! ct = Async.CancellationToken
1315-
// return! t ct
1316-
// }
1317-
1318-
// /// <summary>Return an asynchronous computation that will wait for the given task to complete and return
1319-
// /// its result.</summary>
1320-
// ///
1321-
// /// <remarks>
1322-
// /// This is based on <see href="https://github.com/fsharp/fslang-suggestions/issues/840">Async.Await overload (esp. AwaitTask without throwing AggregateException)</see>
1323-
// /// </remarks>
1324-
// static member inline AwaitCancellableTask
1325-
// ([<InlineIfLambda>] t: CancellationToken -> Task)
1326-
// =
1327-
// asyncEx {
1328-
// let! ct = Async.CancellationToken
1329-
// return! t ct
1330-
// }
1331-
1332-
// type Microsoft.FSharp.Control.Async with
1333-
1334-
// /// <summary>Return an asynchronous computation that will wait for the given task to complete and return
1335-
// /// its result.</summary>
1336-
// static member inline AwaitCancellableTask
1337-
// ([<InlineIfLambda>] t: CancellationToken -> Task<'T>)
1338-
// =
1339-
// async {
1340-
// let! ct = Async.CancellationToken
1341-
1342-
// return!
1343-
// t ct
1344-
// |> Async.AwaitTask
1345-
// }
1346-
1347-
// /// <summary>Return an asynchronous computation that will wait for the given task to complete and return
1348-
// /// its result.</summary>
1349-
// static member inline AwaitCancellableTask
1350-
// ([<InlineIfLambda>] t: CancellationToken -> Task)
1351-
// =
1352-
// async {
1353-
// let! ct = Async.CancellationToken
1354-
1355-
// return!
1356-
// t ct
1357-
// |> Async.AwaitTask
1358-
// }
1359-
1360-
// /// <summary>Runs an asynchronous computation, starting on the current operating system thread.</summary>
1361-
// static member inline AsCancellableTask
1362-
// (computation: Async<'T>)
1363-
// : CancellationToken -> Task<_> =
1364-
// fun ct -> Async.StartImmediateAsTask(computation, cancellationToken = ct)
1365-
13661158
// High priority extensions
13671159
type CancellableTaskResultBuilderBase with
13681160

src/FsToolkit.ErrorHandling.IcedTasks/CancellableTaskResultCE.fs

Lines changed: 0 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -142,58 +142,6 @@ module CancellableTaskResultCE =
142142
: CancellationToken -> Awaiter<TaskAwaiter<_>, _> =
143143
fun ct -> Awaitable.GetTaskAwaiter(x ct)
144144

145-
// member inline this.MergeSources
146-
// (
147-
// [<InlineIfLambda>] left: CancellationToken -> 'Awaiter1,
148-
// [<InlineIfLambda>] right: CancellationToken -> 'Awaiter2
149-
// ) =
150-
// this.Run(
151-
// this.Bind(
152-
// left,
153-
// fun leftR -> this.BindReturn(right, (fun rightR -> struct (leftR, rightR)))
154-
// )
155-
// )
156-
// >> Awaitable.GetTaskAwaiter
157-
158-
159-
// member inline this.MergeSources
160-
// (
161-
// left: 'Awaiter1,
162-
// [<InlineIfLambda>] right: CancellationToken -> 'Awaiter2
163-
// ) =
164-
// this.Run(
165-
// this.Bind(
166-
// left,
167-
// fun leftR -> this.BindReturn(right, (fun rightR -> struct (leftR, rightR)))
168-
// )
169-
// )
170-
// >> Awaitable.GetTaskAwaiter
171-
172-
173-
// member inline this.MergeSources
174-
// (
175-
// [<InlineIfLambda>] left: CancellationToken -> 'Awaiter1,
176-
// right: 'Awaiter2
177-
// ) =
178-
// this.Run(
179-
// this.Bind(
180-
// left,
181-
// fun leftR -> this.BindReturn(right, (fun rightR -> struct (leftR, rightR)))
182-
// )
183-
// )
184-
// >> Awaitable.GetTaskAwaiter
185-
186-
187-
// member inline this.MergeSources(left: 'Awaiter1, right: 'Awaiter2) =
188-
// this.Run(
189-
// this.Bind(
190-
// left,
191-
// fun leftR -> this.BindReturn(right, (fun rightR -> struct (leftR, rightR)))
192-
// )
193-
// )
194-
// >> Awaitable.GetTaskAwaiter
195-
196-
197145
/// Contains methods to build CancellableTasks using the F# computation expression syntax
198146
type BackgroundCancellableTaskResultBuilder() =
199147

@@ -312,49 +260,6 @@ module CancellableTaskResultCE =
312260
let backgroundCancellableTaskResult = BackgroundCancellableTaskResultBuilder()
313261

314262

315-
// /// <summary>
316-
// /// A set of extension methods making it possible to bind against <see cref='T:IcedTasks.CancellableTasks.CancellableTask`1'/> in async computations.
317-
// /// </summary>
318-
// [<AutoOpen>]
319-
// module AsyncExtensions =
320-
321-
// type AsyncExBuilder with
322-
323-
// member inline this.Source([<InlineIfLambda>] t: CancellableTask<'T>) : Async<'T> =
324-
// AsyncEx.AwaitCancellableTask t
325-
326-
// member inline this.Source([<InlineIfLambda>] t: CancellableTask) : Async<unit> =
327-
// AsyncEx.AwaitCancellableTask t
328-
329-
// type Microsoft.FSharp.Control.AsyncBuilder with
330-
331-
// member inline this.Bind
332-
// (
333-
// [<InlineIfLambda>] t: CancellableTask<'T>,
334-
// [<InlineIfLambda>] binder: ('T -> Async<'U>)
335-
// ) : Async<'U> =
336-
// this.Bind(Async.AwaitCancellableTask t, binder)
337-
338-
// member inline this.ReturnFrom([<InlineIfLambda>] t: CancellableTask<'T>) : Async<'T> =
339-
// this.ReturnFrom(Async.AwaitCancellableTask t)
340-
341-
// member inline this.Bind
342-
// (
343-
// [<InlineIfLambda>] t: CancellableTask,
344-
// [<InlineIfLambda>] binder: (unit -> Async<'U>)
345-
// ) : Async<'U> =
346-
// this.Bind(Async.AwaitCancellableTask t, binder)
347-
348-
// member inline this.ReturnFrom([<InlineIfLambda>] t: CancellableTask) : Async<unit> =
349-
// this.ReturnFrom(Async.AwaitCancellableTask t)
350-
351-
// // There is explicitly no Binds for `CancellableTasks` in `Microsoft.FSharp.Control.TaskBuilderBase`.
352-
// // You need to explicitly pass in a `CancellationToken`to start it, you can use `CancellationToken.None`.
353-
// // Reason is I don't want people to assume cancellation is happening without the caller being explicit about where the CancellationToken came from.
354-
// // Similar reasoning for `IcedTasks.ColdTasks.ColdTaskBuilderBase`.
355-
356-
// // Contains a set of standard functional helper function
357-
358263
[<RequireQualifiedAccess>]
359264
module CancellableTaskResult =
360265
open System.Threading.Tasks

0 commit comments

Comments
 (0)