Skip to content

Commit

Permalink
1. Fix examples for synchronized_point.
Browse files Browse the repository at this point in the history
  • Loading branch information
denisandroid committed Aug 31, 2022
1 parent 2239367 commit ff10a76
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 9 deletions.
17 changes: 14 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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) {
Expand Down
17 changes: 14 additions & 3 deletions examples/point.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@

use synchronized::synchronized_point;
use synchronized::synchronized;

/*
An example implementation of synchronized code with
one non-anonymous synchronization point.
Expand All @@ -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) {
Expand Down
12 changes: 12 additions & 0 deletions examples/point_let.rs
Original file line number Diff line number Diff line change
@@ -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.
//
Expand Down
17 changes: 14 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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) {
Expand Down

0 comments on commit ff10a76

Please sign in to comment.