Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Async cache fix in multi-thread-environment for GitHub downloads #1880

Merged
merged 5 commits into from Aug 25, 2016

Conversation

Thorium
Copy link
Member

@Thorium Thorium commented Aug 24, 2016

No comments.

@Thorium
Copy link
Member Author

Thorium commented Aug 25, 2016

Hehe... first some solution and then more optimized. The last one looks quite nice and the unit test proofs it's working while the normal F# Async won't serialize "correctly".

let internal memoizeAsync f =
    let cache = System.Collections.Concurrent.ConcurrentDictionary<'a, System.Threading.Tasks.Task<'b>>()
    fun x -> // task.Result serialization to sync after done.
        cache.GetOrAdd(x, fun x -> f(x) |> Async.StartAsTask) |> Async.AwaitTask

@forki forki merged commit 44fd4ba into fsprojects:master Aug 25, 2016
@forki
Copy link
Member

forki commented Aug 25, 2016

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants