File tree Expand file tree Collapse file tree
tests/Paket.Tests/DependenciesFile Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -31,9 +31,7 @@ let internal memoize (f: 'a -> 'b) : 'a -> 'b =
3131let internal memoizeAsync f =
3232 let cache = System.Collections.Concurrent.ConcurrentDictionary< 'a, System.Threading.Tasks.Task< 'b>>()
3333 fun ( x : 'a ) -> // task.Result serialization to sync after done.
34- cache.GetOrAdd( x, fun x -> // Lazy is needed for "if managed to start multiple before added"
35- let threadfix = lazy ( f( x) |> Async.StartAsTask )
36- threadfix.Force()) |> Async.AwaitTask
34+ cache.GetOrAdd( x, fun x -> f( x) |> Async.StartAsTask) |> Async.AwaitTask
3735
3836type Auth =
3937 | Credentials of Username : string * Password : string
Original file line number Diff line number Diff line change @@ -1359,6 +1359,8 @@ let ``async cache should work``() =
13591359 do ! memFunc " a" |> Async.Ignore
13601360 do ! memFunc " a" |> Async.Ignore
13611361 do ! memFunc " a" |> Async.Ignore
1362+ do ! [| 1 .. 30 |] |> Seq.map( fun _ -> ( memFunc " a" ))
1363+ |> Async.Parallel |> Async.Ignore
13621364 for i = 1 to 30 do
13631365 Async.Start( memFunc " a" |> Async.Ignore )
13641366 Async.Start( memFunc " a" |> Async.Ignore )
@@ -1367,6 +1369,8 @@ let ``async cache should work``() =
13671369 do ! memFunc " a" |> Async.Ignore
13681370 for i = 1 to 30 do
13691371 Async.Start( memFunc " a" |> Async.Ignore )
1372+ do ! [| 1 .. 30 |] |> Seq.map( fun _ -> ( memFunc " a" ))
1373+ |> Async.Parallel |> Async.Ignore
13701374 } |> Async.RunSynchronously
13711375 x |> shouldEqual 1
13721376
You can’t perform that action at this time.
0 commit comments