#concurrency #context #coroutines

sys context

Cooperative multitasking for Rust using Boost.Context

11 releases (5 stable)

Uses old Rust 2015

2.1.0 Feb 2, 2018
2.0.0 Jun 6, 2017
1.0.1 Apr 10, 2017
1.0.0 Mar 2, 2016
0.1.3 Oct 11, 2015

#159 in Concurrency

Download history 981/week @ 2021-07-01 1120/week @ 2021-07-08 1060/week @ 2021-07-15 1188/week @ 2021-07-22 1052/week @ 2021-07-29 1196/week @ 2021-08-05 1114/week @ 2021-08-12 1310/week @ 2021-08-19 1158/week @ 2021-08-26 581/week @ 2021-09-02 1010/week @ 2021-09-09 484/week @ 2021-09-16 542/week @ 2021-09-23 1157/week @ 2021-09-30 1170/week @ 2021-10-07 878/week @ 2021-10-14

3,633 downloads per month
Used in 13 crates (10 directly)

MIT/Apache

2MB
49K SLoC

GNU Style Assembly 47K SLoC // 0.0% comments Assembly 1.5K SLoC // 0.3% comments Rust 557 SLoC // 0.1% comments C 7 SLoC

context-rs

Build Status Build status License

This project offers an easy interface to the famous Boost.Context library and thus provides the building blocks for higher-level abstractions, like coroutines, cooperative threads (userland threads) or an equivalent to C# keyword yield in C++.

API documentation

Usage

To use context, first add this to your Cargo.toml:

[dependencies]
context = "2.0"

And then add this to your source files:

extern crate context;

Performance

The performance heavily depends on the architecture and even on the operating system. A context switch itself is usually as fast as a regular function call though and can thus be viewed as one.

To see this for yourself run cargo bench resume. You can then compare the results of the resume benchmarks (which uses Context::resume()) to the results of resume_reference_perf (which uses regular function calls).

Platforms

Architecture Linux (UNIX) Windows MacOS X iOS
i386 SYSV (ELF) MS (PE) SYSV (MACH-O) -
x86_64 SYSV, X32 (ELF) MS (PE) SYSV (MACH-O) -
arm (aarch32) AAPCS (ELF) AAPCS (PE) - AAPCS (MACH-O)
arm (aarch64) AAPCS (ELF) - - AAPCS (MACH-O)
mips1 O32 (ELF) - - -
ppc32 SYSV (ELF), XCOFF - SYSV (MACH-O) -
ppc64 SYSV (ELF), XCOFF - SYSV (MACH-O) -

Format: ABI (binary format). Source: Boost.Context

Dependencies