From ff10a76ef3bc5433e9e35b8e806323fedd96ef50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B5=D0=BD=D0=B8=D1=81=20=D0=9A=D0=BE=D1=82=D0=BB?= =?UTF-8?q?=D1=8F=D1=80=D0=BE=D0=B2?= Date: Wed, 31 Aug 2022 18:33:10 +0300 Subject: [PATCH] 1. Fix examples for `synchronized_point`. --- README.md | 17 ++++++++++++++--- examples/point.rs | 17 ++++++++++++++--- examples/point_let.rs | 12 ++++++++++++ src/lib.rs | 17 ++++++++++++++--- 4 files changed, 54 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 816295e..d4928ed 100644 --- a/README.md +++ b/README.md @@ -155,9 +155,6 @@ fn main() { ### 4. point ```rust -use synchronized::synchronized_point; -use synchronized::synchronized; - /* An example implementation of synchronized code with one non-anonymous synchronization point. @@ -166,8 +163,22 @@ use synchronized::synchronized; single named sync point. Each synchronization code executes in the same way as ordinary anonymous code, but execution occurs simultaneously in a multi-threaded environment in only one of them. + + !!! In this example, the assembly requires the `point` feature to be active. */ +#[cfg( feature = "point" )] +use synchronized::synchronized_point; +#[cfg( feature = "point" )] +use synchronized::synchronized; + +#[cfg( not(feature = "point") )] +macro_rules! synchronized_point { + [ $($unk:tt)* ] => { + println!("!!! This example requires support for the `point` feature. Run the example with `cargo run --example point --all-features`."); + }; +} + fn main() { // A sync point named `COMB_SYNC` to group anonymous code syncs by name. synchronized_point! {(COMB_SYNC) { diff --git a/examples/point.rs b/examples/point.rs index bfd8d0f..19c87fc 100644 --- a/examples/point.rs +++ b/examples/point.rs @@ -1,7 +1,4 @@ -use synchronized::synchronized_point; -use synchronized::synchronized; - /* An example implementation of synchronized code with one non-anonymous synchronization point. @@ -10,8 +7,22 @@ use synchronized::synchronized; single named sync point. Each synchronization code executes in the same way as ordinary anonymous code, but execution occurs simultaneously in a multi-threaded environment in only one of them. + + !!! In this example, the assembly requires the `point` feature to be active. */ +#[cfg( feature = "point" )] +use synchronized::synchronized_point; +#[cfg( feature = "point" )] +use synchronized::synchronized; + +#[cfg( not(feature = "point") )] +macro_rules! synchronized_point { + [ $($unk:tt)* ] => { + println!("!!! This example requires support for the `point` feature. Run the example with `cargo run --example point --all-features`."); + }; +} + fn main() { // A sync point named `COMB_SYNC` to group anonymous code syncs by name. synchronized_point! {(COMB_SYNC) { diff --git a/examples/point_let.rs b/examples/point_let.rs index bc6035a..5223473 100644 --- a/examples/point_let.rs +++ b/examples/point_let.rs @@ -1,12 +1,24 @@ +#[cfg( feature = "point" )] use synchronized::synchronized_point; +#[cfg( feature = "point" )] use synchronized::synchronized; + /* An example of the implementation of synchronized code with one non-anonymous (named) synchronization point with one mutable variable. + + !!! In this example, the assembly requires the `point` feature to be active. */ +#[cfg( not(feature = "point") )] +macro_rules! synchronized_point { + [ $($unk:tt)* ] => { + println!("!!! This example requires support for the `point` feature. Run the example with `cargo run --example point_let --all-features`."); + }; +} + fn main() { // A sync point named `COMB_SYNC` to group anonymous code syncs by name. // diff --git a/src/lib.rs b/src/lib.rs index 750ef39..b2f0c42 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -168,9 +168,6 @@ fn main() { ### 4. point ```rust -use synchronized::synchronized_point; -use synchronized::synchronized; - /* An example implementation of synchronized code with one non-anonymous synchronization point. @@ -179,8 +176,22 @@ use synchronized::synchronized; single named sync point. Each synchronization code executes in the same way as ordinary anonymous code, but execution occurs simultaneously in a multi-threaded environment in only one of them. + + !!! In this example, the assembly requires the `point` feature to be active. */ +#[cfg( feature = "point" )] +use synchronized::synchronized_point; +#[cfg( feature = "point" )] +use synchronized::synchronized; + +#[cfg( not(feature = "point") )] +macro_rules! synchronized_point { + [ $($unk:tt)* ] => { + println!("!!! This example requires support for the `point` feature. Run the example with `cargo run --example point --all-features`."); + }; +} + fn main() { // A sync point named `COMB_SYNC` to group anonymous code syncs by name. synchronized_point! {(COMB_SYNC) {