-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor!: Rename AsyncLazy/CacheCell -> LazyTask/TaskCell (#433)
- Loading branch information
Showing
12 changed files
with
32 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 6 additions & 6 deletions
12
tests/Equinox.Core.Tests/AsyncLazyTests.fs → tests/Equinox.Core.Tests/LazyTaskTests.fs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,21 @@ | ||
module Equinox.Tests.AsyncLazyTests | ||
module Equinox.Tests.LazyTaskTests | ||
|
||
open Equinox.Core | ||
open Swensen.Unquote | ||
open Xunit | ||
|
||
[<Fact>] | ||
let ``AsyncLazy correctness`` () = async { | ||
let ``LazyTask correctness`` () = async { | ||
// ensure that the encapsulated computation fires only once | ||
let mutable count = 0 | ||
let cell = AsyncLazy(fun () -> task { return System.Threading.Interlocked.Increment &count }) | ||
let cell = LazyTask(fun () -> task { return System.Threading.Interlocked.Increment &count }) | ||
test <@ cell.TryCompleted() |> ValueOption.isNone @> | ||
let! accessResult = [|1 .. 100|] |> Array.map (fun _ -> cell.Await() |> Async.AwaitTask) |> Async.Parallel | ||
test <@ cell.TryCompleted() |> ValueOption.isSome @> | ||
test <@ accessResult |> Array.forall ((=) 1) @> } | ||
|
||
// Pinning the fact that the algorithm is not sensitive to the reuse of the initial value of a cache entry | ||
let [<Fact>] ``AsyncLazy.Empty is a true singleton, does not allocate`` () = | ||
let i1 = AsyncLazy<int>.Empty | ||
let i2 = AsyncLazy<int>.Empty | ||
let [<Fact>] ``LazyTask.Empty is a true singleton, does not allocate`` () = | ||
let i1 = LazyTask<int>.Empty | ||
let i2 = LazyTask<int>.Empty | ||
test <@ obj.ReferenceEquals(i1, i2) @> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters