Skip to content
This repository was archived by the owner on Oct 30, 2019. It is now read-only.

Commit 302d5b5

Browse files
authored
Persist attributes in macro (#20)
* works all the way Signed-off-by: Yoshua Wuyts <[email protected]> * upgrade juliex Signed-off-by: Yoshua Wuyts <[email protected]> * update all deps Signed-off-by: Yoshua Wuyts <[email protected]>
1 parent 5f25b1c commit 302d5b5

File tree

6 files changed

+30
-16
lines changed

6 files changed

+30
-16
lines changed

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ categories = ["asynchronous", "network-programming", "filesystem", "concurrency"
1313
edition = "2018"
1414

1515
[dependencies]
16-
futures-preview = { version = "0.3.0-alpha.15" }
16+
futures-preview = "0.3.0-alpha.15"
1717
runtime-attributes = { path = "runtime-attributes", version = "0.3.0-alpha.2" }
1818
runtime-raw = { path = "runtime-raw", version = "0.3.0-alpha.1" }
1919
runtime-native = { path = "runtime-native", version = "0.3.0-alpha.1" }
@@ -22,11 +22,11 @@ runtime-native = { path = "runtime-native", version = "0.3.0-alpha.1" }
2222
failure = "0.1.5"
2323
futures01 = { package = "futures", version = "0.1" }
2424
futures-preview = { version = "0.3.0-alpha.15", features = ["nightly", "async-await"] }
25-
juliex = "0.3.0-alpha.2"
25+
juliex = "0.3.0-alpha.5"
2626
mio = "0.6.16"
2727
rand = "0.6.5"
2828
runtime-tokio = { path = "runtime-tokio", version = "0.3.0-alpha.1" }
29-
tokio = "0.1.18"
29+
tokio = "0.1.19"
3030

3131
[profile.bench]
3232
codegen-units = 1

runtime-attributes/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ edition = "2018"
1616
proc-macro = true
1717

1818
[dependencies]
19-
syn = { version = "0.15", features = ["full"] }
20-
proc-macro2 = { version = "0.4.24", features = ["nightly"] }
21-
quote = "0.6"
19+
syn = { version = "0.15.33", features = ["full"] }
20+
proc-macro2 = { version = "0.4.29", features = ["nightly"] }
21+
quote = "0.6.12"
2222

2323
[dev-dependencies]
2424
runtime-raw = { path = "../runtime-raw", version = "0.3.0-alpha.1" }

runtime-attributes/src/lib.rs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@ pub fn main(attr: TokenStream, item: TokenStream) -> TokenStream {
3434
let input = syn::parse_macro_input!(item as syn::ItemFn);
3535

3636
let ret = &input.decl.output;
37+
let inputs = &input.decl.inputs;
3738
let name = &input.ident;
3839
let body = &input.block;
40+
let attrs = &input.attrs;
3941

4042
if name != "main" {
4143
let tokens = quote_spanned! { name.span() =>
@@ -52,9 +54,17 @@ pub fn main(attr: TokenStream, item: TokenStream) -> TokenStream {
5254
}
5355

5456
let result = quote! {
55-
fn #name() #ret {
56-
runtime::raw::enter(#rt, async { #body })
57-
}
57+
fn main() #ret {
58+
#(#attrs)*
59+
async fn main(#(#inputs),*) #ret {
60+
#body
61+
}
62+
63+
runtime::raw::enter(#rt, async {
64+
await!(main())
65+
})
66+
}
67+
5868
};
5969

6070
result.into()
@@ -84,6 +94,7 @@ pub fn test(attr: TokenStream, item: TokenStream) -> TokenStream {
8494
let ret = &input.decl.output;
8595
let name = &input.ident;
8696
let body = &input.block;
97+
let attrs = &input.attrs;
8798

8899
if input.asyncness.is_none() {
89100
let tokens = quote_spanned! { input.span() =>
@@ -94,6 +105,7 @@ pub fn test(attr: TokenStream, item: TokenStream) -> TokenStream {
94105

95106
let result = quote! {
96107
#[test]
108+
#(#attrs)*
97109
fn #name() #ret {
98110
runtime::raw::enter(#rt, async { #body })
99111
}
@@ -128,6 +140,7 @@ pub fn bench(attr: TokenStream, item: TokenStream) -> TokenStream {
128140
let args = &input.decl.inputs;
129141
let name = &input.ident;
130142
let body = &input.block;
143+
let attrs = &input.attrs;
131144

132145
if input.asyncness.is_none() {
133146
let tokens = quote_spanned! { input.span() =>
@@ -145,6 +158,7 @@ pub fn bench(attr: TokenStream, item: TokenStream) -> TokenStream {
145158

146159
let result = quote! {
147160
#[bench]
161+
#(#attrs)*
148162
fn #name(b: &mut test::Bencher) {
149163
b.iter(|| {
150164
let _ = runtime::raw::enter(#rt, async { #body });

runtime-native/Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ categories = ["asynchronous", "network-programming", "filesystem", "concurrency"
1313
edition = "2018"
1414

1515
[dependencies]
16-
async-datagram = "2.0.0"
16+
async-datagram = "2.2.0"
1717
futures-preview = "0.3.0-alpha.15"
18-
lazy_static = "1.0.0"
19-
romio = "0.3.0-alpha.5"
18+
lazy_static = "1.3.0"
19+
romio = "0.3.0-alpha.6"
2020
runtime-raw = { path = "../runtime-raw", version = "0.3.0-alpha.1" }
21-
juliex = "0.3.0-alpha.3"
21+
juliex = "0.3.0-alpha.5"

runtime-native/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ pub struct Native;
3838

3939
impl runtime_raw::Runtime for Native {
4040
fn spawn_boxed(&self, fut: BoxFuture<'static, ()>) -> Result<(), SpawnError> {
41-
JULIEX_THREADPOOL.spawn_obj(fut.into());
41+
JULIEX_THREADPOOL.spawn_boxed(fut.into());
4242
Ok(())
4343
}
4444

runtime-tokio/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ edition = "2018"
1515
[dependencies]
1616
futures-preview = { version = "0.3.0-alpha.15", features = ["compat", "io-compat"] }
1717
futures01 = { package = "futures", version = "0.1" }
18-
lazy_static = "1.0.0"
18+
lazy_static = "1.3.0"
1919
mio = "0.6.16"
2020
runtime-raw = { path = "../runtime-raw", version = "0.3.0-alpha.1" }
21-
tokio = { version = "0.1" }
21+
tokio = "0.1.19"

0 commit comments

Comments
 (0)