]> git.lizzy.rs Git - rust.git/commit
Expose whether event loops have active I/O
authorAlex Crichton <alex@alexcrichton.com>
Tue, 11 Feb 2014 03:59:35 +0000 (19:59 -0800)
committerAlex Crichton <alex@alexcrichton.com>
Wed, 12 Feb 2014 17:46:31 +0000 (09:46 -0800)
commitcc34dbb84090f74c84037afb269003f13aa46b78
tree5c23a0f081b5206c2582e8064109da8ac6c5649c
parent1d5c52d8a1d9cc5750aadfbb707584466083ef47
Expose whether event loops have active I/O

The green scheduler can optimize its runtime based on this by deciding to not go
to sleep in epoll() if there is no active I/O and there is a task to be stolen.

This is implemented for librustuv by keeping a count of the number of tasks
which are currently homed. If a task is homed, and then performs a blocking I/O
operation, the count will be nonzero while the task is blocked. The homing count
is intentionally 0 when there are I/O handles, but no handles currently blocked.
The reason for this is that epoll() would only be used to wake up the scheduler
anyway.

The crux of this change was to have a `HomingMissile` contain a mutable borrowed
reference back to the `HomeHandle`. The rest of the change was just dealing with
this fallout. This reference is used to decrement the homed handle count in a
HomingMissile's destructor.

Also note that the count maintained is not atomic because all of its
increments/decrements/reads are all on the same I/O thread.
src/libgreen/basic.rs
src/librustuv/addrinfo.rs
src/librustuv/file.rs
src/librustuv/lib.rs
src/librustuv/net.rs
src/librustuv/pipe.rs
src/librustuv/process.rs
src/librustuv/stream.rs
src/librustuv/timer.rs
src/librustuv/uvio.rs
src/libstd/rt/rtio.rs