Sendable Data Structures, or: How I Learned to Stop Worrying and Love Region Pointers #2816
Labels
A-lifetimes
Area: Lifetimes / regions
A-type-system
Area: Type system
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
E-hard
Call for participation: Hard difficulty. Experience needed to fix: A lot.
Milestone
First of all, all simple data structures (list and map variants) should probably move to libcore - I've been wanting a good O(1) arbitrary-position removal data structure for linked task failure, and it looks like I'll be settling for dvec for now. This will get more and more important the more runtime moves into rust.
But the real problem of linked failure is the sendability requirement. Currently our lists and hashtables are written with @-boxes everywhere. We should have a @-version (for lazy-copy power and for cheapness of allocation) and a ~-version (for inter-task) for each data structure, and ways to convert between each.
But-once-more, ~ data structures will have complicated interfaces. You can't just hand back a ~-pointer to give the user a handle to a node, and disaster will ensue if you try iterating by handing around region pointers but also mutating the data structure at the same time. This hints at problems with mutability, too.
It seems like combining region pointers and mutability, we should be able to let the borrow-checker ensure this sort of property.
fn each
could be defined inimpl for foo_send/&
, andfn remove
defined inimpl for foo_send/&mut
. This might require more powerful propagation of (im)mutability through ~, records, etc.For future (my own) reference, a half-complete attempt at twiddle-ifying hashmap: https://gist.github.com/3057003
The text was updated successfully, but these errors were encountered: