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

Add API for task local data #1857

Closed
brson opened this issue Feb 16, 2012 · 6 comments
Closed

Add API for task local data #1857

brson opened this issue Feb 16, 2012 · 6 comments
Labels
A-runtime Area: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflows C-enhancement Category: An issue proposing an enhancement or a PR with one. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

Comments

@brson
Copy link
Contributor

brson commented Feb 16, 2012

With task local data tasks can stash away a 'control port' in order to move linked failure and task notification into rust code.

See also #553

@brson
Copy link
Contributor Author

brson commented Mar 14, 2012

pcwalton convinced me that we should be cautious about taking this step. For the task failure mechanism I am ok with giving libcore special privileges.

@catamorphism
Copy link
Contributor

Should this be closed, then?

@brson
Copy link
Contributor Author

brson commented Apr 5, 2012

I would like to leave it open a while longer. I haven't decided I don't want it.

@ghost ghost assigned brson Apr 5, 2012
@graydon
Copy link
Contributor

graydon commented Jun 20, 2012

I think we want it. It gives a mechanism for implementing lots of stuff in library code (in particular, the scoped error handlers and dynamic variables I've been thinking of adding).

The API I have in mind is pretty simple. It's a hashtable held off the side of a task. It's keyed by word-sized values (likely taken from the addresses of constants, which are conveniently unique per-process) and the values are (raw_ptr, crust_fn) pairs. The functions are finalizers. The raw pointers, we have no idea what they are. Likely unique boxes of our own choosing. The runtime finalizes the data when the task exits, otherwise user-code is responsible for any other structured get/put operations in this table.

This is an unsafe interface, would have to be used with care. Higher level conveniences (dynamic variables) would be built on top.

@graydon
Copy link
Contributor

graydon commented Jun 20, 2012

Note that it probably also makes sense not to push on it too heavily. I.e. probably keep a single "core::task control structure" as a single task-local value that covers all the needs of core::task and friends, not separately storing every individual field we need as separate task-locals.

@ghost ghost assigned bblum Jun 27, 2012
@bblum
Copy link
Contributor

bblum commented Jun 28, 2012

Implemented. Currently in libcore/task.rs, may end up moving to libcore/tls.rs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-runtime Area: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflows C-enhancement Category: An issue proposing an enhancement or a PR with one. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Projects
None yet
Development

No branches or pull requests

4 participants