mozilla/rust — pull request #1867 by brson (2012-02-19 09:00:53+00:00)
Title: New task API

This is a rewrite of the task API (#1788) based on some ideas niko and I have been tossing around: http://smallcultfollowing.com/babysteps/blog/2012/02/14/using-futures-in-the-task-api/

The goal is to make room for various configuration options and to rewrite the various special forms of spawn in terms of a composable task builder API.

It introduces a task_opts record for static spawn options, and a task_builder type for setting up the options and adding arbitrary setup methods to the spawnee.

It replaces spawn_connected with spawn_listener which, instead of setting up bidirectional communication, just does the hard part of creating a port in the new task and sending the channel back to the original task.

It gets rid of spawn_joinable in favor of using the builder to get a future of the task result.

Spawn no longer returns the nearly useless task value. If it's really needed the builder can be used to, again, get a future of it.

It doesn't make schedulers first class objects yet, both because I am not sold on the idea, and because the runtime requires further changes. It doesn't implement some of the options that are visible in the API, like different scheduling modes and configuring stack sizes.

It is not ready to merge yet. This is just an opportunity for review.