Module std::rt
Runtime services, including the task scheduler and I/O dispatcher
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::local_data
- The interface to local data.std::gc
- The garbage collector.std::unstable::lang
- Miscellaneous lang items, some of which rely onstd::rt
.std::cleanup
- Local heap destruction.std::io
- In the futurestd::io
will use anrt
implementation.std::logging
std::comm
Reexports
pub use self::unwind::{begin_unwind, begin_unwind_raw, begin_unwind_fmt}; |
Modules
args | Global storage for command line arguments |
backtrace | Simple backtrace functionality (to print on failure) Simple backtrace functionality (to print on failure) |
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. |
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 |
rtio | The EventLoop and internal synchronous I/O interface. The EventLoop and internal synchronous I/O interface. |
stack | Rust stack-limit management |
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. |
thread | Bindings to system threading libraries. Bindings to system threading libraries. Native os-thread management |
unwind | Stack unwinding Stack unwinding |
Statics
pub static DEFAULT_ERROR_CODE: int = 101 |
The default error code of the rust runtime if the main task fails instead of exiting cleanly. |
Traits
Runtime | The interface to the current runtime. |
Functions
at_exit | Enqueues a procedure to run when the runtime is cleaned up |
cleanup | One-time runtime cleanup. |
default_sched_threads | Get's the number of scheduler threads requested by the environment
either |
init | One-time runtime initialization. |