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

Consider adding a Concurrent Dictionary (HashMap) #133

Open
fwgreen opened this issue Dec 7, 2021 · 1 comment
Open

Consider adding a Concurrent Dictionary (HashMap) #133

fwgreen opened this issue Dec 7, 2021 · 1 comment
Labels
enhancement New feature or request

Comments

@fwgreen
Copy link

fwgreen commented Dec 7, 2021

This is a major go to in Java and it would be nice to have something similar here. It's safe to assume this would be for the distant future after Swift's concurrency and memory management stories are complete.

@fwgreen fwgreen added the enhancement New feature or request label Dec 7, 2021
@lorentey
Copy link
Member

lorentey commented Dec 9, 2021

Agreed.

Given that we have swift-atomics, this would be technically possible (if a bit painful) to implement right now, although there are some significant API design questions/issues that need to be resolved. (E.g., what constraints would such a type put on its Key/Value types? Do we need to constrain their memory layout in some way? Do they need to conform to AtomicValue in addition to Sendable?)

Similar to a weak dictionary (#2, which is in a sense just a narrow special case of the general concurrent dictionary), it is unlikely that a concurrent dictionary would be able to provide value semantics, or to conform to Collection.

Concurrent data structures feel different enough from regular collection types that they may not be a great fit here -- it may make sense to create a new package that is dedicated to them.

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

No branches or pull requests

2 participants