execution-context 0.1.0

An experimental .NET inspired execution context
Documentation
  • Coverage
  • 87.5%
    7 out of 8 items documented1 out of 1 items with examples
  • Size
  • Source code size: 22.31 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.65 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 16s Average build duration of successful builds.
  • all releases: 16s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • mitsuhiko/rust-execution-context
    36 1 1
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • mitsuhiko

Execution Context for Rust

This implements a .NET inspired execution context. The idea is that something like this could become a core language concept if it can be shown to be reasonably performant.

What are execution contexts?

An execution context is a container for a logical call flow. The idea is that any code that follows the same flow of execution can access flow-local data. An example where this is useful is security relevant data that code might want to carry from operation to operation without accidentally dropping it.

This gives you the most trivial example:

flow_local!(static TEST: u32 = 42);

assert_eq!(*TEST.get(), 42);
let ec = ExecutionContext::capture();
TEST.set(23);

assert_eq!(*TEST.get(), 23);
ec.run(|| {
    assert_eq!(*TEST.get(), 42);
});

Execution contexts can be forwarded to other threads and an API is provided to temporarily or permanently suppress the flow propagation.