| Crates.io | context_bind |
| lib.rs | context_bind |
| version | 0.0.2 |
| created_at | 2016-11-03 01:13:15.263732+00 |
| updated_at | 2016-11-03 02:09:25.657442+00 |
| description | Simple M:N threading library. Should support Linux, MacOS, Free/OpenBSD, and Windows for x86/64, and aarch32/64 |
| homepage | https://github.com/valarauca/context_bind |
| repository | https://github.com/valarauca/context_bind.git |
| max_upload_size | |
| id | 7117 |
| size | 794,538 |
Binds I want out of context-rs
These are simple bindings to context lib. The goal is to make a more object orriented runtime. With a free return function, that can be more easily embedded within external libraries (the goal is to make it easier to embed async-mio functionality).
use context_bind::{Routine,StackSize,swap};
let lambda = Box::new(||{
for i in 0usize.. {
swap(i*2);
}
});
let lambda2 = Box::new(||{
for i in 0usize.. {
swap(i*4);
}
});
let mut dut0 = Routine::new(lambda,1,StackSize::KiB8).unwrap();
let mut dut1 = Routine::new(lambda2,2,StackSize::KiB8).unwrap();
for x in 0..10 {
let a = dut0.exec(0);
let b = dut1.exec(0);
assert_eq!(a,x*2);
assert_eq!(b,x*4);
}
To integrate use the following in your Cargo.toml file.
[dependencies]
context_bindings = "0.0.1"
A special thanks to the authors of context-rs without this library would not exist.