The Rust Runtime, including the task scheduler and I/O
The rt
module provides the private runtime infrastructure necessary
to support core language features like the exchange and local heap,
the garbage collector, logging, local data and unwinding. It also
implements the default task scheduler and task model. Initialization
routines are provided for setting up runtime resources in common
configurations, including that used by rustc
when generating
executables.
It is intended that the features provided by rt
can be factored in a
way such that the core library can be built with different 'profiles'
for different use cases, e.g. excluding the task scheduler. A number
of runtime features though are critical to the functioning of the
language and an implementation must be provided regardless of the
execution environment.
Of foremost importance is the global exchange heap, in the module
global_heap
. Very little practical Rust code can be written without
access to the global heap. Unlike most of rt
the global heap is
truly a global resource and generally operates independently of the
rest of the runtime.
All other runtime features are task-local, including the local heap, the garbage collector, local storage, logging and the stack unwinder.
The relationship between rt
and the rest of the core library is
not entirely clear yet and some modules will be moving into or
out of rt
as development proceeds.
Several modules in core
are clients of rt
:
std::task
- The user-facing interface to the Rust task model.std::task::local_data
- The interface to local data.std::gc
- The garbage collector.std::unstable::lang
- Miscellaneous lang items, some of which rely on std::rt
.std::condition
- Uses local data.std::cleanup
- Local heap destruction.std::io
- In the future std::io
will use an rt
implementation.std::logging
std::pipes
std::comm
std::stackwalk
args | Global storage for command line arguments |
borrowck | |
comm | Simple reimplementation of std::comm Simple reimplementation of std::comm Ports and channels. |
context | CPU context swapping. CPU context swapping. |
crate_map | Crate map Crate map |
env | The runtime configuration, read from environment variables. The runtime configuration, read from environment variables. Runtime environment settings |
global_heap | The global (exchange) heap. The global (exchange) heap. |
io | Synchronous I/O. Synchronous I/O. Synchronous I/O |
kill | Facilities related to task failure, killing, and death. Facilities related to task failure, killing, and death. Task death: asynchronous killing, linked failure, exit code propagation. |
local | The Local trait for types that are accessible via thread-local or task-local storage. The Local trait for types that are accessible via thread-local or task-local storage. |
local_heap | The local, managed heap The local, managed heap The local, garbage collected heap |
local_ptr | The runtime needs to be able to put a pointer into thread-local storage. The runtime needs to be able to put a pointer into thread-local storage. Access to a single thread-local pointer. |
logging | The Logger trait and implementations The Logger trait and implementations |
message_queue | A parallel queue. A parallel queue. A concurrent queue that supports multiple producers and a single consumer. |
rc | Reference counting Reference counting An owned, task-local, reference counted type |
rtio | The EventLoop and internal synchronous I/O interface. The EventLoop and internal synchronous I/O interface. |
sched | The coroutine task scheduler, built on the |
select | Module for private, abstraction-leaking select traits. Wrapped in std::select. |
sleeper_list | A parallel data structure for tracking sleeping schedulers. A parallel data structure for tracking sleeping schedulers. Maintains a shared list of sleeping schedulers. Schedulers use this to wake each other up. |
stack | Stack segments and caching. Stack segments and caching. |
task | Implementations of language-critical runtime features like @. Implementations of language-critical runtime features like @. Language-level runtime services that should reasonably expected to be available 'everywhere'. Local heaps, GC, unwinding, local storage, and logging. Even a 'freestanding' Rust would likely want to implement this. |
test | Tools for testing the runtime Tools for testing the runtime |
thread | Bindings to system threading libraries. Bindings to system threading libraries. |
thread_local_storage | Bindings to pthread/windows thread-local storage. Bindings to pthread/windows thread-local storage. |
tube | A simple single-threaded channel type for passing buffered data between scheduler and task context A simple single-threaded channel type for passing buffered data between scheduler and task context A very simple unsynchronized channel type for sending buffered data from scheduler context to task context. |
util | Just stuff Just stuff |
uv | libuv and default rtio implementation.
libuv and default rtio implementation.
Bindings to libuv, along with the default implementation of |
work_queue | A parallel work-stealing deque. A parallel work-stealing deque. |
cleanup | One-time runtime cleanup. |
in_green_task_context | |
in_sched_context | |
init | One-time runtime initialization. |
run | Execute the main function in a scheduler. |
run_on_main_thread | |
start | Set up a default runtime configuration, given compiler-supplied arguments. |
start_on_main_thread | Like |
Prefix searches with a type followed by a colon (e.g.
fn:
) to restrict the search to a given type.
Accepted types are: fn
, mod
,
struct
(or str
), enum
,
trait
, typedef
(or
tdef
).