mozilla/rust — pull request #6821 by brson (2013-05-30 01:46:38+00:00)
Title: Scheduler multithreading

r? @nikomatsakis

This implements very basic multithreading in the new scheduler. This is only using a very basic work *sharing* strategy with a shared task queue. To do so it adds three new concurrent types to the scheduler: `WorkQueue`, `MessageQueue`, and `SleeperList`. `WorkQueue` is temporarily just a basic queue; `MessageQueue` is a multiple-producer, singe-consumer queue for sending messages to schedulers, and `SleeperList` is a shared stack used for waking up sleeping schedulers. All three are intended to be lock free but for now are implemented naively with locks.

The main scheduler routine, which uses all three of these data structures is here: https://github.com/brson/rust/blob/io-upstream/src/libstd/rt/sched.rs#L144

An example of how the multithreaded scheduler is constructed: https://github.com/brson/rust/blob/io-upstream/src/libstd/rt/test.rs#L62