diff options
| author | Jonathan Reem <jonathan.reem@gmail.com> | 2014-11-13 18:04:28 -0800 |
|---|---|---|
| committer | Jonathan Reem <jonathan.reem@gmail.com> | 2014-11-13 22:57:33 -0800 |
| commit | 93c4942690753e982cbb4bf6667940da71c5d286 (patch) | |
| tree | 5cd06a4031ab7b8ec510eaf36e5b677e4dfcdd02 /src/rustllvm/RustWrapper.cpp | |
| parent | 15ba87f0314fda5e81603f37ae5f40e2022bcfc1 (diff) | |
| download | rust-93c4942690753e982cbb4bf6667940da71c5d286.tar.gz rust-93c4942690753e982cbb4bf6667940da71c5d286.zip | |
Rewrite std::sync::TaskPool to be load balancing and panic-resistant
The previous implementation was very likely to cause panics during unwinding through this process: - child panics, drops its receiver - taskpool comes back around and sends another job over to that child - the child receiver has hung up, so the taskpool panics on send - during unwinding, the taskpool attempts to send a quit message to the child, causing a panic during unwinding - panic during unwinding causes a process abort This meant that TaskPool upgraded any child panic to a full process abort. This came up in Iron when it caused crashes in long-running servers. This implementation uses a single channel to communicate between spawned tasks and the TaskPool, which significantly reduces the complexity of the implementation and cuts down on allocation. The TaskPool uses the channel as a single-producer-multiple-consumer queue. Additionally, through the use of send_opt and recv_opt instead of send and recv, this TaskPool is robust on the face of child panics, both before, during, and after the TaskPool itself is dropped. Due to the TaskPool no longer using an `init_fn_factory`, this is a [breaking-change] otherwise, the API has not changed. If you used `init_fn_factory` in your code, and this change breaks for you, you can instead use an `AtomicUint` counter and a channel to move information into child tasks.
Diffstat (limited to 'src/rustllvm/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions
