Skip to content

Redesign task API #1788

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

Closed
brson opened this issue Feb 9, 2012 · 5 comments
Closed

Redesign task API #1788

brson opened this issue Feb 9, 2012 · 5 comments
Assignees
Labels
C-cleanup Category: PRs that clean code up or issues documenting cleanup.

Comments

@brson
Copy link
Contributor

brson commented Feb 9, 2012

It's a bit messy and uncomposable. There are various things we would like to be able to do but can't yet - set min rust stack size, set c stack size, perform operations on schedulers, specify 1:1 thread-to-task scheduling mode, add various hooks to either the spawner or spawnee.

Some unimplemented ideas are in #1721.

See also #595

@nikomatsakis
Copy link
Contributor

I have some thoughts on this. I will try to mock up a prototype and see if they make sense before writing them out here.

@brson
Copy link
Contributor Author

brson commented Feb 9, 2012

I know you do and I was hoping you would help :-D

@nikomatsakis
Copy link
Contributor

So, I had this crazy idea involving bind that would allow us to create tasks with all kinds of options in a very flexible way. I tried implementing it and found it was elegant in theory but a horrible mess in practice. Therefore, I was thinking that something simple would work better.

For example, a base task API that takes an options struct along with a unique closure:

enum task = uint;
fn defaults() -> opts;
fn spawn(opts: opts, body: fn~()) -> task;

then we can have a couple of other modules encapsulating common patterns. For example an actor module that creates a task with its own mailbox so that others can send messages to it, or a future module that creates a task that computes a result. I elaborated out those two examples in a blog post so I won't repeat it here.

This isn't so different from what we have now, I guess, just a bit better organized. Is it too simple, or workable?

@nikomatsakis
Copy link
Contributor

Brian and I had a sit-down on this. The end-result was a builder-based API that makes some use of futures. I documented the ideas here:

http://smallcultfollowing.com/babysteps/blog/2012/02/14/using-futures-in-the-task-api/

@brson
Copy link
Contributor Author

brson commented Feb 15, 2012

Unsupervise should be an operation parents perform on children, not on themselves.

This was referenced Feb 19, 2012
@ghost ghost assigned brson Feb 19, 2012
@brson brson closed this as completed Feb 21, 2012
celinval pushed a commit to celinval/rust-dev that referenced this issue Jun 4, 2024
Kobzol added a commit to Kobzol/rust that referenced this issue Dec 30, 2024
bors pushed a commit to rust-lang-ci/rust that referenced this issue Jan 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-cleanup Category: PRs that clean code up or issues documenting cleanup.
Projects
None yet
Development

No branches or pull requests

2 participants