Blei/rustTracks — pull request #1 by brson (2013-12-06 22:37:38+00:00)
Title: Restructure tasks to avoid deadlock

This restructures the way your tasks are organized to hopefully avoid the deadlock situations you were hitting.

Now, I don't actually know precisely what was causing your deadlock here, but the way this is laid out now is the typical pattern for GUI applications in Rust:

* Instead of using `main` use `#[start]`, then manually initialize the runtime with `rt::start_on_main_thread`. The GUI event loop runs on the main task and is pinned, by itself, to the main thread. By doing this you guarantee that the GTK event loop never blocks any other code (and that it runs on the applications main thread, which is important on non-linuxes).
* Then all the worker threads that do typical, non-blocking, Rusty things just use the normal `spawn` function.

Notice that this is kind of the opposite of the pattern you had where the GUI event loop thread was on a normal task and all the other tasks were given their own thread.