commit_hash stringlengths 40 40 | author stringlengths 1 57 | date timestamp[s]date 2010-07-26 04:45:09 2026-04-14 18:21:10 | message stringlengths 8 1.39M | diff stringlengths 68 51.2k | files_changed int64 1 136 | insertions int64 0 2.35k | deletions int64 0 1.9k |
|---|---|---|---|---|---|---|---|
a517d6a5d1e638687d3d82657634b03e5a7c94f0 | Xudong Huang | 2018-07-10T06:20:35 | :pencil: fix clippy warnings | diff --git a/src/detail/x86_64_unix.rs b/src/detail/x86_64_unix.rs
index 9202055..865633c 100644
--- a/src/detail/x86_64_unix.rs
+++ b/src/detail/x86_64_unix.rs
@@ -11,7 +11,7 @@ extern "C" {
}
#[cfg(nightly)]
-mod asm {
+mod asm_impl {
use super::Registers;
/// prefetch data
#[inline]
@@ -84,7 +84,7... | 5 | 22 | 19 |
04e862c5b673766695038a323bcaa9996e2d40f7 | Xudong Huang | 2018-07-09T02:18:34 | :gift: bump version to 0.6.10 | diff --git a/Cargo.toml b/Cargo.toml
index f36ff95..d7e196b 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "generator"
-version = "0.6.9"
+version = "0.6.10"
authors = ["Xudong Huang <huangxu008@hotmail.com>"]
license = "MIT/Apache-2.0"
repository = "https://github.com/Xudong-Huang/gener... | 1 | 1 | 1 |
c02da81c9015af893940c412e3b624ac1b5e4261 | Xudong Huang | 2018-07-09T01:48:51 | :pencil: use Vec<T> as default raw buffer allocator | diff --git a/src/alloc.rs b/src/alloc.rs
index 4a63e25..2e8c299 100644
--- a/src/alloc.rs
+++ b/src/alloc.rs
@@ -4,17 +4,20 @@ pub struct RawVec<T> {
}
impl<T> RawVec<T> {
+ #[inline]
pub fn with_capacity(cap: usize) -> Self {
RawVec {
buf: Vec::with_capacity(cap),
}
}
... | 3 | 11 | 16 |
56cd4438e46aac52fa8ec8014f8b0d7f40360ca7 | Xudong Huang | 2018-05-17T01:40:52 | :pencil: bump version to 0.6.9 | diff --git a/Cargo.toml b/Cargo.toml
index d07c612..f36ff95 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "generator"
-version = "0.6.8"
+version = "0.6.9"
authors = ["Xudong Huang <huangxu008@hotmail.com>"]
license = "MIT/Apache-2.0"
repository = "https://github.com/Xudong-Huang/genera... | 2 | 2 | 1 |
565d234e8e65c09b82dcdfeca54822f43cda0a26 | Xudong Huang | 2018-05-17T01:34:31 | :bug: fix unix nighlty swap_register | diff --git a/src/detail/x86_64_unix.rs b/src/detail/x86_64_unix.rs
index cc1ee3a..45a3464 100644
--- a/src/detail/x86_64_unix.rs
+++ b/src/detail/x86_64_unix.rs
@@ -43,7 +43,7 @@ mod asm {
asm!(
""
:
- : "{rcx}"(out_regs), "{rdx}"(in_regs)
+ : "{rdi}"(out_regs), ... | 1 | 1 | 1 |
3305b9f0ce7c69d59aab5ccd83fd38a7b3c98127 | Xudong Huang | 2018-05-07T08:33:38 | :gift: bump package version | diff --git a/Cargo.toml b/Cargo.toml
index 7e568d7..aba068b 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "generator"
-version = "0.6.6"
+version = "0.6.7"
authors = ["Xudong Huang <huangxu008@hotmail.com>"]
license = "MIT/Apache-2.0"
repository = "https://github.com/Xudong-Huang/genera... | 1 | 1 | 1 |
46cf606c2ae7d6ec20dab676f5aef5ef943b1c2d | Xudong Huang | 2018-05-07T08:28:29 | :bug: work around naked function problem in rustc (#6) | diff --git a/Cargo.toml b/Cargo.toml
index 27727fe..7e568d7 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -25,14 +25,6 @@ log = "0.4"
rustc_version = "0.2"
cc = "1.0"
-# debug build (#6)
-[profile.dev]
-opt-level = 1
-
-# test build (#6)
-[profile.test]
-opt-level = 1
-
# release build
[profile.release]
lto = true... | 3 | 21 | 16 |
61176c68089654357aa08a956843005468d79f71 | Xudong Huang | 2018-05-07T07:23:19 | :bug: fix rustc 1.27.0-nightly debug broken (#6) | diff --git a/Cargo.toml b/Cargo.toml
index 2f4c0f1..27727fe 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -25,5 +25,14 @@ log = "0.4"
rustc_version = "0.2"
cc = "1.0"
+# debug build (#6)
+[profile.dev]
+opt-level = 1
+
+# test build (#6)
+[profile.test]
+opt-level = 1
+
+# release build
[profile.release]
lto = true... | 3 | 13 | 1 |
aab77ec97bed25b860537c97c8db9104b463e4cd | Xudong Huang | 2018-03-02T05:39:40 | :gift: bump version to 0.6.6 | diff --git a/Cargo.toml b/Cargo.toml
index 76b53a7..2f4c0f1 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "generator"
-version = "0.6.5"
+version = "0.6.6"
authors = ["Xudong Huang <huangxu008@hotmail.com>"]
license = "MIT/Apache-2.0"
repository = "https://github.com/Xudong-Huang/genera... | 1 | 2 | 2 |
4f18fcb628595744ad188314ee8296f318830fde | Xudong Huang | 2018-02-05T06:29:19 | :pencil: disallow thread_local in stable | diff --git a/src/rt.rs b/src/rt.rs
index 10ace24..e64b5ad 100644
--- a/src/rt.rs
+++ b/src/rt.rs
@@ -21,6 +21,7 @@ thread_local!(static ROOT_CONTEXT: Box<Context> = {
// when ROOT_CONTEXT get inialized. but in debug mode it
// will be zero in generator context since the stack changed
// to a different place, be care... | 1 | 18 | 4 |
8f081936b2d00cd6333716e58216d1dc0090b64a | Xudong Huang | 2018-02-05T05:59:44 | :rocket: speed up TLS access
this improve the context swap from 37ns to 30ns, about 23% speed up! | diff --git a/benches/lib.rs b/benches/lib.rs
index 695309f..291b58c 100644
--- a/benches/lib.rs
+++ b/benches/lib.rs
@@ -170,14 +170,15 @@ fn init_gen(b: &mut Bencher) {
});
}
-
#[bench]
fn fnbox_bench(b: &mut Bencher) {
use std::boxed::FnBox;
b.iter(|| {
let a: [usize; 100] = [0; 100];
-... | 10 | 75 | 34 |
fc4c4e9ed5c996ccab911c34d6ede2729251557d | Xudong Huang | 2018-02-01T06:41:26 | :pencil: remove useless get_ref_ptr() | diff --git a/src/gen_impl.rs b/src/gen_impl.rs
index bc19f7c..c71bd20 100644
--- a/src/gen_impl.rs
+++ b/src/gen_impl.rs
@@ -226,13 +226,6 @@ impl<'a, A, T> GeneratorImpl<'a, A, T> {
self.context.err.take()
}
- /// get the _ref pointer, this is used for coroutine cancel
- /// don't call this funct... | 1 | 0 | 7 |
fd2ffd827454f6379ae1619d3d05995ef83bee65 | Xudong Huang | 2018-01-03T05:04:21 | :pencil: bump crate version | diff --git a/Cargo.toml b/Cargo.toml
index 89a174d..76b53a7 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "generator"
-version = "0.6.4"
+version = "0.6.5"
authors = ["Xudong Huang <huangxu008@hotmail.com>"]
license = "MIT/Apache-2.0"
repository = "https://github.com/Xudong-Huang/genera... | 1 | 1 | 1 |
8a82baf023eb9d2d0e7e0a022b8088b2ff5871a4 | Xudong Huang | 2017-10-11T03:55:41 | :pencil: bump version | diff --git a/Cargo.toml b/Cargo.toml
index 4dc3cb2..c35b29e 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "generator"
-version = "0.6.0"
+version = "0.6.1"
authors = ["Xudong Huang <huangxu008@hotmail.com>"]
license = "LGPL-2.1"
repository = "https://github.com/Xudong-Huang/generator-rs... | 1 | 1 | 1 |
5f1f44ebdfee34aa17bad6c2e73d4d8bee73ff27 | Eh2406 | 2017-09-14T17:54:53 | clarify types for rust/pull/44287 | diff --git a/examples/send.rs b/examples/send.rs
index e87343d..c129b2a 100644
--- a/examples/send.rs
+++ b/examples/send.rs
@@ -4,7 +4,7 @@ use generator::{Gn, yield_};
fn sum(a: u32) -> u32 {
let mut sum = a;
- let mut recv;
+ let mut recv: u32;
while sum < 200 {
// println!("sum={} ", sum... | 1 | 1 | 1 |
1bf05d124efc5356fab5987e99d723ac324c7478 | Xudong Huang | 2017-10-09T05:30:04 | :pencil: update gcc crate to cc crate | diff --git a/Cargo.toml b/Cargo.toml
index a459219..4dc3cb2 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -23,7 +23,7 @@ log = "0.3"
[build-dependencies]
rustc_version = "0.2"
-gcc = "0.3"
+cc = "1.0"
[profile.release]
opt-level=3
diff --git a/build.rs b/build.rs
index b4118d3..b219fb9 100644
--- a/build.rs
+++ b... | 2 | 3 | 3 |
75e24e2606c31ba1dc276665c64a34469b3f9e3c | Xudong Huang | 2017-09-17T13:19:43 | :pencil: add exclude for package | diff --git a/Cargo.toml b/Cargo.toml
index fce629e..a459219 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "generator"
-version = "0.5.0"
+version = "0.6.0"
authors = ["Xudong Huang <huangxu008@hotmail.com>"]
license = "LGPL-2.1"
repository = "https://github.com/Xudong-Huang/generator-rs... | 1 | 7 | 1 |
def90d0f7255b93eecfd23210fef1a3ef26180cd | Xudong Huang | 2017-09-03T09:21:10 | :pencil: stable use std Vec as raw buf alloc | diff --git a/src/alloc.rs b/src/alloc.rs
new file mode 100644
index 0000000..a581451
--- /dev/null
+++ b/src/alloc.rs
@@ -0,0 +1,19 @@
+#[derive(Debug)]
+pub struct RawVec<T> {
+ buf: Vec<T>,
+}
+
+impl<T> RawVec<T> {
+ pub fn with_capacity(cap: usize) -> Self {
+ RawVec { buf: Vec::with_capacity(cap) }
+ ... | 3 | 25 | 0 |
d52c73b9c9dc4512b4c0b8ccbf7b3ea4a0a9c901 | Xudong Huang | 2017-09-01T03:50:44 | :pencil: conditional type_name usage for nightly | diff --git a/src/gen_impl.rs b/src/gen_impl.rs
index 197d990..f828f41 100644
--- a/src/gen_impl.rs
+++ b/src/gen_impl.rs
@@ -8,7 +8,6 @@ use std::panic;
use std::thread;
use std::any::Any;
use std::marker::PhantomData;
-use std::intrinsics::type_name;
use scope::Scope;
use yield_::yield_now;
@@ -363,16 +362,20 @... | 2 | 34 | 26 |
3c23ee429e4239ae7a5d660c772cb3865ad5c303 | Xudong Huang | 2017-09-01T03:27:48 | :pencil: replace unstable fnbox | diff --git a/src/gen_impl.rs b/src/gen_impl.rs
index c56f110..197d990 100644
--- a/src/gen_impl.rs
+++ b/src/gen_impl.rs
@@ -7,7 +7,6 @@ use std::fmt;
use std::panic;
use std::thread;
use std::any::Any;
-use std::boxed::FnBox;
use std::marker::PhantomData;
use std::intrinsics::type_name;
@@ -20,6 +19,17 @@ use r... | 2 | 44 | 20 |
6a664f58fee06df92d7d63e6e1ef210bd560be03 | Xudong Huang | 2017-09-01T03:01:56 | :gift: add nightly detection build | diff --git a/Cargo.toml b/Cargo.toml
index 0e242f9..e964601 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -10,6 +10,13 @@ description = "Generator Library in Rust"
readme = "README.md"
keywords = ["generator", "coroutine", "green", "thread", "fiber"]
categories = ["data-structures", "algorithms"]
+build = "build.rs"
+... | 3 | 25 | 7 |
b823bf471a1ca69c2173a45e5b380c3e2b2d621d | Xudong Huang | 2017-03-24T07:27:13 | add categories to algorithms and data-structures | diff --git a/Cargo.toml b/Cargo.toml
index 084fea2..0e242f9 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -9,6 +9,7 @@ documentation = "https://docs.rs/generator"
description = "Generator Library in Rust"
readme = "README.md"
keywords = ["generator", "coroutine", "green", "thread", "fiber"]
+categories = ["data-struct... | 1 | 1 | 0 |
4836040134dd45c13283921fdf1a29c7602bb3a6 | Xudong Huang | 2017-03-15T05:27:55 | fix rust nightly 1.17 issue | diff --git a/examples/cd.rs b/examples/cd.rs
index 4c35a8b..94f483f 100644
--- a/examples/cd.rs
+++ b/examples/cd.rs
@@ -1,4 +1,3 @@
-#[macro_use]
extern crate generator;
use generator::*;
diff --git a/src/detail/x86_64_windows.rs b/src/detail/x86_64_windows.rs
index cdb5b0a..d1f12ce 100644
--- a/src/detail/x86_64_... | 4 | 24 | 8 |
56f70475680f695d1f4e1f2835c9477e88f6af5d | Xudong Huang | 2017-01-25T11:20:28 | fix root co_get_yield bug | diff --git a/src/rt.rs b/src/rt.rs
index e0110a8..b39e015 100644
--- a/src/rt.rs
+++ b/src/rt.rs
@@ -135,19 +135,19 @@ impl ContextStack {
/// get the coroutine context
#[inline]
- pub fn co_ctx(&self) -> &'static mut Context {
+ pub fn co_ctx(&self) -> Option<&'static mut Context> {
let root... | 3 | 14 | 7 |
fd948bf643785cc6008f51069dc1aee2b2d9da5a | Xudong Huang | 2016-12-29T14:41:02 | fix get_local_data bug | diff --git a/src/rt.rs b/src/rt.rs
index 3b1b060..e0110a8 100644
--- a/src/rt.rs
+++ b/src/rt.rs
@@ -198,8 +198,18 @@ pub fn is_generator() -> bool {
#[inline]
pub fn get_local_data() -> *mut u8 {
let env = ContextStack::current();
- let ctx = env.co_ctx();
- ctx.local_data
+ let root = unsafe {&mut *en... | 1 | 12 | 2 |
19687cc3daeafc7e97f05712c0e881d6fb7bb458 | Xudong Huang | 2016-12-29T05:13:38 | add number example | diff --git a/examples/number.rs b/examples/number.rs
new file mode 100644
index 0000000..d2dbf36
--- /dev/null
+++ b/examples/number.rs
@@ -0,0 +1,30 @@
+#[macro_use]
+extern crate generator;
+use generator::*;
+
+fn factors(n: u32) -> Generator<'static, (), u32> {
+ Gn::new_scoped(move |mut s| {
+ if n == 0 ... | 1 | 30 | 0 |
c8eaa973d70dbf7ff9804beea9bbaf5bfab7f39b | Xudong Huang | 2016-12-28T08:45:57 | fix co_ctx algorithm | diff --git a/src/lib.rs b/src/lib.rs
index aa4bf79..fb0657b 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -26,6 +26,7 @@ mod yield_;
mod gen_impl;
mod reg_context;
+pub use rt::Error;
pub use scope::Scope;
pub use rt::{get_local_data, is_generator};
pub use gen_impl::{Gn, Generator, GeneratorImpl};
diff --git a/sr... | 3 | 19 | 14 |
5ce8bfc66b8d64b9eb8e5ddfa8411dcbc5d7d648 | Xudong Huang | 2016-12-16T05:23:56 | update cd_player example | diff --git a/examples/cd.rs b/examples/cd.rs
index 0e7ba37..4c35a8b 100644
--- a/examples/cd.rs
+++ b/examples/cd.rs
@@ -8,7 +8,7 @@ enum Action {
Stop,
}
-#[derive(Debug, Clone, Copy, PartialEq)]
+#[derive(Debug, Clone, Copy)]
enum State {
Playing,
Stopped,
@@ -21,34 +21,40 @@ fn main() {
let m... | 1 | 30 | 24 |
d0503c10cc3d94921611a4ae8c97adb1d982461b | Xudong Huang | 2016-12-14T05:52:40 | update pipe example | diff --git a/examples/pipe.rs b/examples/pipe.rs
index 879037b..8379377 100644
--- a/examples/pipe.rs
+++ b/examples/pipe.rs
@@ -1,30 +1,32 @@
-#![feature(conservative_impl_trait)]
-#[macro_use]
+// #![feature(conservative_impl_trait)]
+#[macro_use]
extern crate generator;
use generator::*;
fn main() {
- fn s... | 1 | 19 | 17 |
47f6a344a537fa68fadc7a096325a8f4abf8aac7 | Xudong Huang | 2016-12-13T09:16:37 | add more examples | diff --git a/examples/cd.rs b/examples/cd.rs
new file mode 100644
index 0000000..0e7ba37
--- /dev/null
+++ b/examples/cd.rs
@@ -0,0 +1,54 @@
+#[macro_use]
+extern crate generator;
+use generator::*;
+
+#[derive(Debug)]
+enum Action {
+ Play(&'static str),
+ Stop,
+}
+
+#[derive(Debug, Clone, Copy, PartialEq)]
+en... | 2 | 84 | 0 |
ab034c53e92469050bee45eb87b347102d340a19 | Xudong Huang | 2016-12-13T04:25:11 | cancel panic print nothing | diff --git a/src/gen_impl.rs b/src/gen_impl.rs
index 4d37406..c56f110 100644
--- a/src/gen_impl.rs
+++ b/src/gen_impl.rs
@@ -258,18 +258,32 @@ impl<'a, A, T> GeneratorImpl<'a, A, T> {
ret.expect("send got None return")
}
+ /// cancel the generator without any check
+ #[inline]
+ unsafe fn raw_c... | 1 | 19 | 5 |
5be203ec0175b8adbf1c35c1100eb6987986da26 | Xudong Huang | 2016-12-13T04:03:12 | cancel panic right after resumed | diff --git a/benches/lib.rs b/benches/lib.rs
index 093f0d6..02cf13e 100644
--- a/benches/lib.rs
+++ b/benches/lib.rs
@@ -56,7 +56,7 @@ fn single_yield_bench(b: &mut Bencher) {
loop {
let v: Option<usize> = yield_(i);
i += 1;
- match v {
+ match v {
... | 5 | 20 | 24 |
baa41737a27fd0f6c0c1ce8adf2b6fd52441c1dc | Xudong Huang | 2016-12-13T02:38:04 | add yield_with for scope | diff --git a/src/scope.rs b/src/scope.rs
index 462cbf8..e75af02 100644
--- a/src/scope.rs
+++ b/src/scope.rs
@@ -34,7 +34,7 @@ impl<A, T> Scope<A, T> {
/// get current generator send para
#[inline]
- fn get_para(&mut self) -> Option<A> {
+ pub fn get_yield(&mut self) -> Option<A> {
let para =... | 1 | 13 | 7 |
f3199250360cd6b18e510caf2bca676649b8b922 | Xudong Huang | 2016-12-13T02:15:20 | update yield_from | diff --git a/examples/yield_from.rs b/examples/yield_from.rs
new file mode 100644
index 0000000..145ac95
--- /dev/null
+++ b/examples/yield_from.rs
@@ -0,0 +1,26 @@
+#[macro_use]
+extern crate generator;
+use generator::*;
+
+fn xrange(start: u32, end: u32) -> u32 {
+ for i in start..end {
+ yield_with(i);
+ ... | 5 | 49 | 10 |
bd65392d600363d05c4b961aaa9389153021ae1c | Xudong Huang | 2016-12-12T06:37:39 | use expect instead of unwrap for send | diff --git a/src/gen_impl.rs b/src/gen_impl.rs
index 69df08e..ea4e4f9 100644
--- a/src/gen_impl.rs
+++ b/src/gen_impl.rs
@@ -255,7 +255,7 @@ impl<'a, A, T> GeneratorImpl<'a, A, T> {
/// send interface
pub fn send(&mut self, para: A) -> T {
let ret = self.raw_send(Some(para));
- ret.unwrap()
+ ... | 1 | 1 | 1 |
1c4a90ac865554f2e5e1ceaa982672d2f2f7fad7 | Xudong Huang | 2016-12-12T06:30:19 | support done macro | diff --git a/examples/fib.rs b/examples/fib.rs
index 7e48193..e6c778f 100644
--- a/examples/fib.rs
+++ b/examples/fib.rs
@@ -1,33 +1,19 @@
+#[macro_use]
extern crate generator;
-use generator::{Gn, yield_with};
+use generator::Gn;
fn main() {
-
- let g = Gn::<()>::new(|| {
+ let g = Gn::new_scoped(|mut s| {
... | 5 | 45 | 22 |
9de625ca13d02fe3d4c202b1f2d0a703cbbb8b62 | Xudong Huang | 2016-12-08T07:11:23 | support coroutine cancel | diff --git a/src/gen_impl.rs b/src/gen_impl.rs
index 6bde189..8abf5cd 100644
--- a/src/gen_impl.rs
+++ b/src/gen_impl.rs
@@ -18,7 +18,7 @@ use reg_context::RegContext;
// default stack size, in usize
// windows has a minimal size as 0x4a8!!!!
-pub const DEFAULT_STACK_SIZE: usize = 0x800;
+pub const DEFAULT_STACK_SI... | 1 | 9 | 2 |
ff855a19ee1fc63fe039d08f3e7c79bcfdad75c8 | Xudong Huang | 2016-12-07T10:30:03 | refine some code | diff --git a/src/gen_impl.rs b/src/gen_impl.rs
index 101b1d8..6bde189 100644
--- a/src/gen_impl.rs
+++ b/src/gen_impl.rs
@@ -4,7 +4,6 @@
//!
use std::fmt;
-use std::mem;
use std::panic;
use std::thread;
use std::any::Any;
@@ -37,7 +36,16 @@ impl<A> Gn<A> {
T: 'a,
A: 'a
{
- ... | 5 | 38 | 32 |
d28e09734aa97122e5ef5673ce96b1af55102719 | Xudong Huang | 2016-12-07T02:02:04 | remame Context to RegContex | diff --git a/src/gen_impl.rs b/src/gen_impl.rs
index 310425c..101b1d8 100644
--- a/src/gen_impl.rs
+++ b/src/gen_impl.rs
@@ -15,7 +15,7 @@ use std::intrinsics::type_name;
use scope::Scope;
use yield_::yield_now;
use rt::{Error, Context, ContextStack};
-use reg_context::Context as RegContext;
+use reg_context::RegCon... | 4 | 22 | 22 |
769be15927864fdc5917d69735445b307f407d53 | Xudong Huang | 2016-11-18T03:28:53 | make generator cancel unsafe | diff --git a/benches/lib.rs b/benches/lib.rs
index 6550331..093f0d6 100644
--- a/benches/lib.rs
+++ b/benches/lib.rs
@@ -57,13 +57,9 @@ fn single_yield_bench(b: &mut Bencher) {
let v: Option<usize> = yield_(i);
i += 1;
match v {
- Some(x) => {
- ... | 3 | 32 | 19 |
8e47d50575802a3ca75b9c8d5f4c00de27461456 | Xudong Huang | 2016-10-24T05:33:39 | fix panic passing | diff --git a/src/gen_impl.rs b/src/gen_impl.rs
index 1cf9d9a..587011a 100644
--- a/src/gen_impl.rs
+++ b/src/gen_impl.rs
@@ -156,7 +156,8 @@ impl<'a, A, T> GeneratorImpl<'a, A, T> {
}
if let Some(err) = self.context.err.take() {
- panic!(err);
+ // pass the error to the parent ... | 2 | 25 | 9 |
a59210a9008bc8b989c9ac6002ecdf82646c30f1 | Xudong Huang | 2016-10-24T02:55:50 | fix panic logic | diff --git a/src/gen_impl.rs b/src/gen_impl.rs
index 362006d..1cf9d9a 100644
--- a/src/gen_impl.rs
+++ b/src/gen_impl.rs
@@ -148,11 +148,15 @@ impl<'a, A, T> GeneratorImpl<'a, A, T> {
// swap to the generator
RegContext::swap(cur, &mut top.regs);
- // check the panic status
+ // comes ... | 4 | 28 | 64 |
163d68ea94024b65f174c94daf7bf707a3e7f82f | Xudong Huang | 2016-10-23T09:36:32 | refine panic error check | diff --git a/src/gen_impl.rs b/src/gen_impl.rs
index 18b411c..362006d 100644
--- a/src/gen_impl.rs
+++ b/src/gen_impl.rs
@@ -307,25 +307,43 @@ fn gen_init(_: usize, f: *mut usize) -> ! {
func();
};
+ fn check_err(cause: Box<Any + Send + 'static>) {
+ match cause.downcast_ref::<Error>() {
+ ... | 2 | 33 | 14 |
0cbdbefc87a941e6e97fe59552af6d6612f9db07 | Xudong Huang | 2016-09-21T06:36:22 | add back is_generator | diff --git a/src/lib.rs b/src/lib.rs
index ed7a7bf..ef047b9 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -28,6 +28,6 @@ mod gen_impl;
mod reg_context;
pub use scope::Scope;
-pub use rt::get_local_data;
+pub use rt::{get_local_data, is_generator};
pub use gen_impl::{Gn, Generator, GeneratorImpl};
pub use yield_::{y... | 2 | 3 | 3 |
3de8e96774250f3ab2b7c5b0d9105a8ff8d139ae | Xudong Huang | 2016-09-20T11:46:59 | only coroutine support local data | diff --git a/src/rt.rs b/src/rt.rs
index 08280f5..6f5fd58 100644
--- a/src/rt.rs
+++ b/src/rt.rs
@@ -178,10 +178,18 @@ pub fn is_generator() -> bool {
}
/// get the current context local data
+/// only coroutine support local data
#[inline]
pub fn get_local_data() -> *mut u8 {
let env = ContextStack::current... | 1 | 9 | 1 |
9c0b71e971e414fefe265c9d42f3ebe4a7b0d997 | Xudong Huang | 2016-09-20T11:18:31 | remove is_generator export | diff --git a/src/lib.rs b/src/lib.rs
index ef047b9..ed7a7bf 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -28,6 +28,6 @@ mod gen_impl;
mod reg_context;
pub use scope::Scope;
-pub use rt::{get_local_data, is_generator};
+pub use rt::get_local_data;
pub use gen_impl::{Gn, Generator, GeneratorImpl};
pub use yield_::{y... | 2 | 2 | 1 |
5ed4c3863982a24ed2e94cb98b7259922a9db375 | Xudong Huang | 2016-09-20T08:00:51 | add co_get_yield | diff --git a/src/lib.rs b/src/lib.rs
index 95a9bf7..ef047b9 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -30,4 +30,4 @@ mod reg_context;
pub use scope::Scope;
pub use rt::{get_local_data, is_generator};
pub use gen_impl::{Gn, Generator, GeneratorImpl};
-pub use yield_::{yield_, yield_with, yield_from, get_yield, co_y... | 2 | 16 | 8 |
b36022e02e482214e38c97cebc14a47c1d231654 | Xudong Huang | 2016-09-08T08:21:55 | move prefetch to asm | diff --git a/src/detail/mod.rs b/src/detail/mod.rs
index 8cf13b1..f13b603 100644
--- a/src/detail/mod.rs
+++ b/src/detail/mod.rs
@@ -30,7 +30,7 @@ pub mod asm;
#[path = "x86_64_windows.rs"]
pub mod asm;
-pub use self::asm::{Registers, swap_registers, initialize_call_frame};
+pub use self::asm::{Registers, swap_regi... | 3 | 27 | 18 |
49f48b5d71b5a50d2bc2e12cf02d9a2094e11d59 | Xudong Huang | 2016-09-08T07:59:28 | fix coroutine yield from generator context bug | diff --git a/src/detail/mod.rs b/src/detail/mod.rs
index d94bcc8..8cf13b1 100644
--- a/src/detail/mod.rs
+++ b/src/detail/mod.rs
@@ -45,7 +45,7 @@ fn align_down(sp: *mut usize) -> *mut usize {
#[naked]
pub fn prefetch(data: *const usize) {
unsafe {
- asm!("prefetcht2 $0"
+ asm!("prefetcht1 $0"
... | 4 | 39 | 7 |
16bda6b7e89c9104189640c87cf7e7e9e4def6e1 | Xudong Huang | 2016-09-07T13:34:01 | add coroutine prefetch | diff --git a/src/detail/mod.rs b/src/detail/mod.rs
index 5a8f3cc..d94bcc8 100644
--- a/src/detail/mod.rs
+++ b/src/detail/mod.rs
@@ -38,6 +38,21 @@ fn align_down(sp: *mut usize) -> *mut usize {
sp as *mut usize
}
+
+/// prefetch data
+#[cfg(target_arch = "x86_64")]
+#[inline]
+#[naked]
+pub fn prefetch(data: *c... | 5 | 39 | 2 |
535872f7ecdc5899da576744d034604369094433 | Xudong Huang | 2016-08-27T12:06:24 | impl Send for static generator | diff --git a/src/gen_impl.rs b/src/gen_impl.rs
index 81b1a88..00b01c6 100644
--- a/src/gen_impl.rs
+++ b/src/gen_impl.rs
@@ -28,6 +28,7 @@ pub struct Gn<A> {
/// the generator type
pub type Generator<'a, A, T> = Box<GeneratorImpl<'a, A, T>>;
+unsafe impl<A, T> Send for GeneratorImpl<'static, A, T> {}
impl<A> Gn<... | 1 | 1 | 0 |
846242ddbb5dae4d23568936cba5509f3fa43147 | Xudong Huang | 2016-08-26T03:24:33 | add get_local_data for generator | diff --git a/src/gen_impl.rs b/src/gen_impl.rs
index 513aa1a..81b1a88 100644
--- a/src/gen_impl.rs
+++ b/src/gen_impl.rs
@@ -48,11 +48,11 @@ impl<A: Any> Gn<A> {
pub fn new<'a, T: Any, F>(f: F) -> Box<GeneratorImpl<'a, A, T>>
where F: FnOnce() -> T + 'a
{
- Self::new_opt(f, DEFAULT_STACK_SIZE)... | 1 | 9 | 2 |
cbf4b8e3e2ae6b0ce7a750b226f24469cca4d656 | Xudong Huang | 2016-08-25T14:31:05 | add local data interface | diff --git a/src/gen_impl.rs b/src/gen_impl.rs
index 73fe851..513aa1a 100644
--- a/src/gen_impl.rs
+++ b/src/gen_impl.rs
@@ -150,6 +150,12 @@ impl<'a, A, T> GeneratorImpl<'a, A, T> {
mem::replace(&mut self.para, Some(para));
}
+ /// set the generator local data
+ #[inline]
+ pub fn set_local_da... | 3 | 17 | 1 |
30433f299116e593fa813fac493795db9ba6d091 | Xudong Huang | 2016-08-24T03:30:14 | add co_yield_with for coroutine | diff --git a/src/lib.rs b/src/lib.rs
index 4597f26..472fe87 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -30,4 +30,4 @@ mod reg_context;
pub use scope::Scope;
pub use rt::is_generator;
pub use gen_impl::{Gn, Generator, GeneratorImpl};
-pub use yield_::{yield_, yield_with, yield_from, get_yield};
+pub use yield_::{yie... | 3 | 9 | 2 |
b51067909fae5287ddd3635c7f980cbd036f647c | Xudong Huang | 2016-08-24T02:52:08 | add golbal is_generator for current context | diff --git a/Cargo.toml b/Cargo.toml
index dd399bc..e6a7401 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "generator"
-version = "0.3.0"
+version = "0.4.0"
authors = ["Xudong Huang <huangxu008@hotmail.com>"]
license = "MIT/ISC"
repository = "https://github.com/Xudong-Huang/generator-rs.... | 3 | 17 | 11 |
2d8ce91089226c502793d308ab67c295b2ae66b9 | Xudong Huang | 2016-08-24T02:23:07 | use link list to manage context runtime | diff --git a/src/gen_impl.rs b/src/gen_impl.rs
index c882667..73fe851 100644
--- a/src/gen_impl.rs
+++ b/src/gen_impl.rs
@@ -123,13 +123,12 @@ impl<'a, A, T> GeneratorImpl<'a, A, T> {
#[inline]
fn resume_gen(&mut self) {
let env = ContextStack::current();
+ // get the current regs
let... | 4 | 71 | 39 |
855df762d91009b50c0217f320f4790b458b3caa | Xudong Huang | 2016-08-23T14:18:20 | remove get_context | diff --git a/src/gen_impl.rs b/src/gen_impl.rs
index aa45c29..c882667 100644
--- a/src/gen_impl.rs
+++ b/src/gen_impl.rs
@@ -151,12 +151,6 @@ impl<'a, A, T> GeneratorImpl<'a, A, T> {
mem::replace(&mut self.para, Some(para));
}
- /// prepare the para that passed into generator before send
- #[inlin... | 4 | 1 | 17 |
c9721c9784ef20d9b8a13335f02687f2b6a9d405 | Xudong Huang | 2016-08-17T03:22:08 | fix windows xmm registers issue | diff --git a/src/detail/mod.rs b/src/detail/mod.rs
index 688f6db..5a8f3cc 100644
--- a/src/detail/mod.rs
+++ b/src/detail/mod.rs
@@ -30,19 +30,7 @@ pub mod asm;
#[path = "x86_64_windows.rs"]
pub mod asm;
-pub use self::asm::{swap_registers, initialize_call_frame};
-
-#[repr(C)]
-#[derive(Debug)]
-pub struct Registe... | 4 | 49 | 15 |
07fde4fce74fc37cad64d56c77b6f4ad0eca78b4 | Xudong Huang | 2016-08-17T01:11:34 | add more support for coroutine | diff --git a/src/gen_impl.rs b/src/gen_impl.rs
index 12f938f..aa45c29 100644
--- a/src/gen_impl.rs
+++ b/src/gen_impl.rs
@@ -145,6 +145,34 @@ impl<'a, A, T> GeneratorImpl<'a, A, T> {
self.f.is_none()
}
+ /// prepare the para that passed into generator before send
+ #[inline]
+ pub fn set_para(&... | 4 | 40 | 3 |
f4e1cb90c9e55f3b1fcf46ccf11dc804b3919006 | Xudong Huang | 2016-08-12T06:30:57 | use naked pure asm functions | diff --git a/src/detail/x86_64_unix.rs b/src/detail/x86_64_unix.rs
index 2bdb182..97fbfec 100644
--- a/src/detail/x86_64_unix.rs
+++ b/src/detail/x86_64_unix.rs
@@ -11,7 +11,8 @@ pub fn initialize_call_frame(regs: &mut Registers,
stack: &Stack) {
#[inline(never)]
- unsafe fn boot... | 3 | 15 | 12 |
8edfad64c4257d5b07993f86d10479885e19e376 | Xudong Huang | 2016-08-10T10:48:52 | use UnsafeCell for ContextStack | diff --git a/src/gen_impl.rs b/src/gen_impl.rs
index 37cbe02..12f938f 100644
--- a/src/gen_impl.rs
+++ b/src/gen_impl.rs
@@ -14,7 +14,6 @@ use std::intrinsics::type_name;
use scope::Scope;
use yield_::yield_now;
-// use generator::Generator;
use rt::{Error, Context, ContextStack};
use reg_context::Context as RegC... | 2 | 30 | 32 |
f95e365ddba2d3f8d4b016b4ef0c333f777e9b9c | Xudong Huang | 2016-08-10T10:31:05 | remove Generator trait | diff --git a/src/gen_impl.rs b/src/gen_impl.rs
index b7151bd..37cbe02 100644
--- a/src/gen_impl.rs
+++ b/src/gen_impl.rs
@@ -27,6 +27,9 @@ pub struct Gn<A> {
dummy: PhantomData<A>,
}
+/// the generator type
+pub type Generator<'a, A, T> = Box<GeneratorImpl<'a, A, T>>;
+
impl<A> Gn<A> {
/// create a scoped... | 4 | 11 | 63 |
ee13fdab603ca46e60a78957673176f334314b86 | Xudong Huang | 2016-08-10T07:05:52 | refine init procedure and make the re-init safe | diff --git a/benches/lib.rs b/benches/lib.rs
index c768749..6550331 100644
--- a/benches/lib.rs
+++ b/benches/lib.rs
@@ -1,4 +1,5 @@
#![feature(test)]
+#![feature(fnbox)]
extern crate generator;
extern crate test;
@@ -131,7 +132,6 @@ fn create_gen(b: &mut Bencher) {
});
}
-
#[bench]
fn init_gen(b: &mut B... | 5 | 53 | 54 |
4b716cc3f490ea0f9e82a4d1f3da0c5982ee74d3 | Xudong Huang | 2016-08-10T01:27:13 | don't use Generator trait
inline some functoin to improve performance
add support for generator re-init
add bench for generator create and init | diff --git a/benches/lib.rs b/benches/lib.rs
index d173664..c768749 100644
--- a/benches/lib.rs
+++ b/benches/lib.rs
@@ -79,7 +79,6 @@ fn single_yield_bench(b: &mut Bencher) {
});
}
-
#[bench]
fn scoped_yield_bench(b: &mut Bencher) {
let mut g = Gn::new_scoped(|mut s| {
@@ -110,3 +109,55 @@ fn scoped_yie... | 8 | 161 | 82 |
15bc0bdd59851203f7772ca288e1c0b11be2b15f | Xudong Huang | 2016-08-09T23:16:14 | refine generator impl new method | diff --git a/src/gen_impl.rs b/src/gen_impl.rs
index e25fa1e..982d188 100644
--- a/src/gen_impl.rs
+++ b/src/gen_impl.rs
@@ -32,9 +32,9 @@ impl<A> Gn<A> {
T: 'a,
A: 'a
{
- let (mut g, s) = GeneratorImpl::<A, T, _>::new_scope(DEFAULT_STACK_SIZE);
- g.f = Some(move || f(s)... | 3 | 59 | 35 |
bb4b7ccd52795c5a6c8964e1bbcb1ee5edd4ebf5 | Xudong Huang | 2016-08-07T09:41:28 | add scoped example | diff --git a/examples/fib.rs b/examples/fib.rs
index 892e54e..7e48193 100644
--- a/examples/fib.rs
+++ b/examples/fib.rs
@@ -13,7 +13,21 @@ fn main() {
a + b
});
+ let g1 = Gn::<()>::new_scoped(|mut scope| {
+ let (mut a, mut b) = (0, 1);
+ while b < 200 {
+ std::mem::swap(&m... | 2 | 26 | 8 |
871c1bbaa539e647ff2b4503ca6bc7868c127d74 | Xudong Huang | 2016-08-07T07:29:30 | add scoped test and bench | diff --git a/benches/lib.rs b/benches/lib.rs
index cf67841..d173664 100644
--- a/benches/lib.rs
+++ b/benches/lib.rs
@@ -78,3 +78,35 @@ fn single_yield_bench(b: &mut Bencher) {
i += 1;
});
}
+
+
+#[bench]
+fn scoped_yield_bench(b: &mut Bencher) {
+ let mut g = Gn::new_scoped(|mut s| {
+ let mut... | 3 | 74 | 1 |
1f52e2a336f3926fa808d42a3f22cf548ad3b292 | Xudong Huang | 2016-08-07T06:55:25 | add scoped generator | diff --git a/src/detail/x86_64_windows.rs b/src/detail/x86_64_windows.rs
index 4b05571..7c2e521 100644
--- a/src/detail/x86_64_windows.rs
+++ b/src/detail/x86_64_windows.rs
@@ -63,7 +63,11 @@ pub fn initialize_call_frame(regs: &mut Registers,
*mut_offset(sp, -7) = bootstrap_green_task as usize; // release RET
... | 6 | 196 | 50 |
39ab32f38f3fd3d9c27430a9938b6c1daf23b92a | Xudong Huang | 2016-08-02T01:34:42 | bump up version to 0.3.0 | diff --git a/Cargo.toml b/Cargo.toml
index 59eea7c..dd399bc 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "generator"
-version = "0.2.0"
+version = "0.3.0"
authors = ["Xudong Huang <huangxu008@hotmail.com>"]
license = "MIT/ISC"
repository = "https://github.com/Xudong-Huang/generator-rs.... | 1 | 1 | 1 |
cab2cf5a0eac99a67ad73fa18dcabdee45495381 | Xudong Huang | 2016-08-05T12:48:21 | fix yield from test | diff --git a/tests/lib.rs b/tests/lib.rs
index 6fbe298..eb5a638 100644
--- a/tests/lib.rs
+++ b/tests/lib.rs
@@ -289,20 +289,22 @@ fn test_yield_from_send() {
i * 2
});
- yield_from(g1);
+ let i = yield_from(g1).unwrap();
+ assert_eq!(i, 10);
// here we need a unu... | 1 | 8 | 6 |
79d100b9708b7dfb721ba1fcc5475bfb7c1bf15d | Xudong Huang | 2016-08-05T11:25:21 | update yield_ logic same as python | diff --git a/benches/lib.rs b/benches/lib.rs
index 5d202a4..cf67841 100644
--- a/benches/lib.rs
+++ b/benches/lib.rs
@@ -51,8 +51,10 @@ fn single_yield_with_bench(b: &mut Bencher) {
#[bench]
fn single_yield_bench(b: &mut Bencher) {
let mut g = Gn::new(|| {
- for i in 0usize.. {
+ let mut i = 0;
+ ... | 4 | 46 | 14 |
571fa2701acb0f722973a9e70578fa283281d867 | Xudong Huang | 2016-08-05T10:30:33 | add Debug for generator | diff --git a/src/generator.rs b/src/generator.rs
index 4a0cc0d..54c7a7b 100644
--- a/src/generator.rs
+++ b/src/generator.rs
@@ -3,6 +3,9 @@
//! generator trait
//!
+use std::fmt;
+use std::intrinsics::type_name;
+
/// generator trait
pub trait Generator<A> {
/// Output type
@@ -36,3 +39,14 @@ impl<'a, A, T>... | 3 | 20 | 2 |
f742db006a42f8d6d681aa35553ff91e24924d5e | Xudong Huang | 2016-08-04T11:03:45 | filter panic update | diff --git a/src/gen_impl.rs b/src/gen_impl.rs
index f2df090..bdc2772 100644
--- a/src/gen_impl.rs
+++ b/src/gen_impl.rs
@@ -218,7 +218,10 @@ fn gen_init(_: usize, f: *mut usize) -> ! {
}
}
} else {
- error!("Panicked inside: {:?}", cause.downcast::<&str... | 1 | 4 | 1 |
08365e32acc3708c6cd74abdafff7e0e1468ab05 | Xudong Huang | 2016-08-04T10:24:00 | improve rt get/set para performance | diff --git a/src/rt.rs b/src/rt.rs
index e816419..fa7eba4 100644
--- a/src/rt.rs
+++ b/src/rt.rs
@@ -63,8 +63,9 @@ impl Context {
where A: Any
{
let para = unsafe { &mut *self.para };
- if para.is::<Option<A>>() {
- para.downcast_mut::<Option<A>>().unwrap().take()
+ let v... | 1 | 5 | 4 |
d3d433cedb7e5dbe6dea05522ae24f1bea572064 | Xudong Huang | 2016-08-04T05:45:25 | fix rt context stack tls issue | diff --git a/src/rt.rs b/src/rt.rs
index ea37225..e816419 100644
--- a/src/rt.rs
+++ b/src/rt.rs
@@ -5,17 +5,13 @@
use std::mem;
use std::any::Any;
-use std::cell::UnsafeCell;
use stack::Stack;
use reg_context::Context as RegContext;
/// each thread has it's own generator context stack
-thread_local!(static ... | 1 | 8 | 11 |
2ac3996e8a075f04e2f4b02ce36e77dbb0f88104 | Xudong Huang | 2016-08-04T04:26:00 | reduce TLS access for raw_yield_now | diff --git a/src/yield_.rs b/src/yield_.rs
index 2fd0862..229a3ab 100644
--- a/src/yield_.rs
+++ b/src/yield_.rs
@@ -22,9 +22,20 @@ pub fn yield_now() {
}
}
+#[inline]
+fn raw_yield_now(env: &mut ContextStack, cur: &mut Context) {
+ let sp = &cur.stack;
+ // judge if this is root context
+ if sp.size()... | 1 | 22 | 7 |
7a5fc0e63301c5da006ec726e8ebd3da947bef9c | Xudong Huang | 2016-08-04T03:26:04 | reduce TLS access for yield_() | diff --git a/src/yield_.rs b/src/yield_.rs
index cc39309..2fd0862 100644
--- a/src/yield_.rs
+++ b/src/yield_.rs
@@ -53,7 +53,12 @@ pub fn yield_with<T: Any>(v: T) {
#[inline]
pub fn get_yield<A: Any>() -> Option<A> {
let context = ContextStack::current().top();
+ raw_get_yield(context)
+}
+/// get the pass... | 1 | 8 | 2 |
c3ca4542b5b34d167fb0a65510f42e672a9dccbe | Xudong Huang | 2016-08-04T03:17:45 | add more bench | diff --git a/benches/lib.rs b/benches/lib.rs
index 3affbe8..5d202a4 100644
--- a/benches/lib.rs
+++ b/benches/lib.rs
@@ -10,6 +10,7 @@ use test::Bencher;
#[allow(dead_code)]
fn yield_bench(b: &mut Bencher) {
// don't print any panic info
+ // when cancel the generator
panic::set_hook(Box::new(|_| {}));
... | 2 | 29 | 2 |
66b7c1d6519886caf461e8f8a768968d7d25f49d | Xudong Huang | 2016-08-03T15:09:36 | perf adjust | diff --git a/benches/lib.rs b/benches/lib.rs
index 3d32421..3affbe8 100644
--- a/benches/lib.rs
+++ b/benches/lib.rs
@@ -6,7 +6,8 @@ use std::panic;
use generator::*;
use test::Bencher;
-#[bench]
+// #[bench]
+#[allow(dead_code)]
fn yield_bench(b: &mut Bencher) {
// don't print any panic info
panic::set_... | 4 | 10 | 7 |
8a7c9f211bd36cc30eddee8f3f6f0d5ddf0380c3 | Xudong Huang | 2016-08-03T09:04:03 | disable lto optimization
windows can't find rlib for log when enable lto | diff --git a/Cargo.toml b/Cargo.toml
index 384be67..59eea7c 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -11,4 +11,3 @@ keywords = ["generator", "coroutine", "green", "thread", "fiber"]
[profile.release]
opt-level=3
-lto=true | 1 | 0 | 1 |
a1b553033f63673dd569bfa2d37bae6e1c5d7c5e | Xudong Huang | 2016-08-03T08:45:56 | add bench test | diff --git a/Cargo.toml b/Cargo.toml
index 66b7cdd..384be67 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -9,3 +9,6 @@ readme = "README.md"
homepage = "https://github.com/Xudong-Huang/generator-rs.git"
keywords = ["generator", "coroutine", "green", "thread", "fiber"]
+[profile.release]
+opt-level=3
+lto=true
diff --g... | 3 | 52 | 2 |
bb4daaf3f4336c908c80fa0054336396ae7eed00 | Xudong Huang | 2016-08-03T03:33:01 | update according to clippy | diff --git a/src/gen_impl.rs b/src/gen_impl.rs
index 428c874..ca231b7 100644
--- a/src/gen_impl.rs
+++ b/src/gen_impl.rs
@@ -43,7 +43,7 @@ impl<A: Any> Gn<A> {
}
}
-/// GeneratorImpl
+/// `GeneratorImpl`
pub struct GeneratorImpl<A: Any, T: Any, F>
where F: FnOnce() -> T
{
diff --git a/src/reg_context.rs ... | 4 | 6 | 6 |
830c84729832e0344d04d2d94d815710273f64b4 | Xudong Huang | 2016-08-03T03:13:45 | fix unix stack | diff --git a/src/detail/x86_64_unix.rs b/src/detail/x86_64_unix.rs
index 9855244..2bdb182 100644
--- a/src/detail/x86_64_unix.rs
+++ b/src/detail/x86_64_unix.rs
@@ -1,5 +1,6 @@
use detail::{align_down, mut_offset};
use reg_context::InitFn;
+use stack::Stack;
use super::Registers;
@@ -7,7 +8,7 @@ pub fn initializ... | 3 | 10 | 8 |
b564c971dd47e490a58694da430767f0991a0d52 | Xudong Huang | 2016-08-03T01:37:27 | fix windows stack limit issue
window has it's own stack check framework, we need to follow that
the minimal stack size requred is 0x4a8 usize in debug version | diff --git a/src/detail/x86_64_windows.rs b/src/detail/x86_64_windows.rs
index 3ae23ba..8a54d5d 100644
--- a/src/detail/x86_64_windows.rs
+++ b/src/detail/x86_64_windows.rs
@@ -1,5 +1,6 @@
use detail::{align_down, mut_offset};
use reg_context::InitFn;
+use stack::Stack;
use super::Registers;
@@ -7,8 +8,9 @@ pub ... | 5 | 85 | 37 |
be8466f9bec4a48a91b01696e1edde2fd8514a33 | Xudong Huang | 2016-08-02T06:10:31 | add support for windows | diff --git a/src/detail/x86_64_windows.rs b/src/detail/x86_64_windows.rs
new file mode 100644
index 0000000..3ae23ba
--- /dev/null
+++ b/src/detail/x86_64_windows.rs
@@ -0,0 +1,100 @@
+use detail::{align_down, mut_offset};
+use reg_context::InitFn;
+
+use super::Registers;
+
+pub fn initialize_call_frame(regs: &mut Reg... | 1 | 100 | 0 |
0342fd6633781b4687cc8147dc08f7680fb03a36 | Xudong Huang | 2016-08-02T06:07:21 | update for 1.12 nightly | diff --git a/src/detail/mod.rs b/src/detail/mod.rs
index 0045b8e..688f6db 100644
--- a/src/detail/mod.rs
+++ b/src/detail/mod.rs
@@ -22,13 +22,27 @@
// the `rust_swap_registers` function, but that's only because for now segmented
// stacks are disabled.
-#[cfg(target_arch = "x86_64")]
-#[cfg(not(windows))]
-pub use... | 5 | 36 | 75 |
27aa2cc3f0f44bc92595cedd7faf848b4fb0d741 | Xudong Huang | 2016-06-20T02:30:41 | update for rust 1.9
update according to clippy | diff --git a/src/gen_impl.rs b/src/gen_impl.rs
index 93de6f3..1e0653f 100644
--- a/src/gen_impl.rs
+++ b/src/gen_impl.rs
@@ -204,7 +204,7 @@ fn gen_init(_: usize, f: *mut usize) -> ! {
// we can't panic inside the generator context
// need to propagate the panic to the main thread
- if let Er... | 5 | 9 | 11 |
b48401703d61ade6d10c2824a5388daddf70f2d8 | Xudong Huang | 2016-03-29T05:50:15 | update for rust 1.7 | diff --git a/src/gen_impl.rs b/src/gen_impl.rs
index 7aa5289..93de6f3 100644
--- a/src/gen_impl.rs
+++ b/src/gen_impl.rs
@@ -5,6 +5,7 @@
use std::mem;
+use std::panic;
use std::thread;
use std::any::Any;
use std::boxed::FnBox;
@@ -203,7 +204,7 @@ fn gen_init(_: usize, f: *mut usize) -> ! {
// we can'... | 3 | 5 | 3 |
b944bd11067ffcda434d14f1a1e8065480ab07f5 | Xudong Huang | 2015-11-14T10:55:45 | yield from non generator context do nothing | diff --git a/src/yield_.rs b/src/yield_.rs
index a882e12..fcb2309 100644
--- a/src/yield_.rs
+++ b/src/yield_.rs
@@ -27,8 +27,10 @@ pub fn yield_now() {
fn raw_yield<T: Any>(context: &mut Context, v: T) {
// check the context
if !context.is_generator() {
- error!("yield run at none generator context")... | 2 | 17 | 2 |
353a2fa4a2831872b938952242772e39a9e576f4 | Xudong Huang | 2015-11-08T11:22:35 | pub GeneratorImpl for deriving | diff --git a/src/gen_impl.rs b/src/gen_impl.rs
index f4ba2a0..7aa5289 100644
--- a/src/gen_impl.rs
+++ b/src/gen_impl.rs
@@ -68,6 +68,7 @@ impl<'a, A: Any, T: Any, F> GeneratorImpl<A, T, F>
}
}
+ /// init a heap based generator
pub fn init(&mut self) {
self.context.para = &mut self.para... | 2 | 2 | 1 |
c77e1a3d0be44f65ae52c57e35bc2ba70109e652 | Xudong Huang | 2015-11-10T11:45:28 | refine gen_impl init | diff --git a/src/gen_impl.rs b/src/gen_impl.rs
index 82f3b1f..f4ba2a0 100644
--- a/src/gen_impl.rs
+++ b/src/gen_impl.rs
@@ -35,8 +35,9 @@ impl <A: Any> Gn<A> {
pub fn new_opt<'a, T: Any, F>(f: F, size: usize) -> Box<Generator<A, Output = T> + 'a>
where F: FnOnce() -> T + 'a
{
- let g = Box::n... | 1 | 5 | 5 |
85a339a04df63e5dc8fad57ce4f92ff702dc56b6 | Xudong Huang | 2015-11-10T11:28:35 | remove _yield!() macro | diff --git a/examples/send.rs b/examples/send.rs
index aa4af78..f98f5b3 100644
--- a/examples/send.rs
+++ b/examples/send.rs
@@ -1,12 +1,12 @@
-#[macro_use]
extern crate generator;
+use generator::{Gn, yield_};
fn sum(a: u32) -> u32 {
let mut sum = a;
let mut recv = 1u32;
while sum < 200 {
s... | 4 | 18 | 25 |
78d04669cfd5ea7792a754328128297096aa5381 | Xudong Huang | 2015-11-10T11:19:27 | remove load_register | diff --git a/src/detail/mod.rs b/src/detail/mod.rs
index 6f432c6..0045b8e 100644
--- a/src/detail/mod.rs
+++ b/src/detail/mod.rs
@@ -24,7 +24,7 @@
#[cfg(target_arch = "x86_64")]
#[cfg(not(windows))]
-pub use self::x86_64_unix::{Registers, swap_registers, load_registers, initialize_call_frame};
+pub use self::x86_64... | 3 | 4 | 35 |
1675450467e681bea7ece345e0d373cf2869abe3 | Xudong Huang | 2015-11-08T10:25:17 | change version to 0.2.0 | diff --git a/Cargo.toml b/Cargo.toml
index 44ccb9c..66b7cdd 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "generator"
-version = "0.1.0"
+version = "0.2.0"
authors = ["Xudong Huang <huangxu008@hotmail.com>"]
license = "MIT/ISC"
repository = "https://github.com/Xudong-Huang/generator-rs.... | 1 | 1 | 1 |
bc8cbfb8fdc87dc3082e50b76d7443ce4c13165b | Xudong Huang | 2015-11-08T09:57:28 | move coroutine to other lib | diff --git a/Cargo.toml b/Cargo.toml
index 105d871..44ccb9c 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,7 +1,7 @@
[package]
name = "generator"
version = "0.1.0"
-authors = ["Xudong Huang <xudongh@juniper.net>"]
+authors = ["Xudong Huang <huangxu008@hotmail.com>"]
license = "MIT/ISC"
repository = "https://github... | 5 | 1 | 215 |
ef8859fd4c142977fb3ce586024f121bb20240b4 | Xudong Huang | 2015-11-09T15:41:58 | compact stack support | diff --git a/examples/stack_resize.rs b/examples/compact.rs
similarity index 67%
rename from examples/stack_resize.rs
rename to examples/compact.rs
index 764a56a..9d885e9 100644
--- a/examples/stack_resize.rs
+++ b/examples/compact.rs
@@ -1,6 +1,6 @@
#[macro_use]
extern crate generator;
-use generator::Gn;
+use gener... | 7 | 64 | 61 |
234d39b9d890fc632090cbf1646bf2a565650068 | Xudong Huang | 2015-11-08T18:33:31 | fix commit | diff --git a/examples/send.rs b/examples/send.rs
index 75418ef..aa4af78 100644
--- a/examples/send.rs
+++ b/examples/send.rs
@@ -14,7 +14,7 @@ fn sum(a: u32) -> u32 {
fn main() {
// we specify the send type is u32
- let mut s = generator!(sum(0), <u32>);
+ let mut s = generator::Gn::<u32>::new(||sum(0));
... | 2 | 1 | 24 |
3afcd88854d2883d7f13cc26e0b462573f22b175 | Xudong Huang | 2015-11-08T18:17:54 | add init for gen impl | diff --git a/src/gen_impl.rs b/src/gen_impl.rs
index aa278dc..0573f08 100644
--- a/src/gen_impl.rs
+++ b/src/gen_impl.rs
@@ -36,28 +36,8 @@ impl <A: Any> Gn<A> {
pub fn new_opt<'a, T: Any, F>(f: F, size: usize) -> Box<Generator<A, Output = T> + 'a>
where F: FnOnce() -> T + 'a
{
- let mut g = B... | 1 | 25 | 23 |
3b9c070673e7e7a0b25e5880294f609e397aa034 | Xudong Huang | 2015-11-08T17:53:49 | odd stack size for full foot print test | diff --git a/examples/stack_resize.rs b/examples/stack_resize.rs
index 7418f1d..764a56a 100644
--- a/examples/stack_resize.rs
+++ b/examples/stack_resize.rs
@@ -15,7 +15,7 @@ fn fib(a: u32, b: u32) -> u32 {
}
fn get_gen() -> Box<Generator<(), Output = u32>> {
- Gn::<()>::new(|| fib(0, 1))
+ Gn::<()>::new_opt(... | 3 | 7 | 7 |
9f60d8fa42a874ad6f8b518091c187122dd0c29c | Xudong Huang | 2015-11-06T10:29:14 | add coroutine implementation | diff --git a/src/coroutine.rs b/src/coroutine.rs
new file mode 100644
index 0000000..d9bf040
--- /dev/null
+++ b/src/coroutine.rs
@@ -0,0 +1,112 @@
+//! # generator
+//!
+//! coroutine implementation
+//! coroutine is static life time generator
+//! rust doesn't support get typeid for non-static types
+//! and doesn't ... | 2 | 112 | 2 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.