Skip to content

Commit ff10a76

Browse files
committed
1. Fix examples for synchronized_point.
1 parent 2239367 commit ff10a76

File tree

4 files changed

+54
-9
lines changed

4 files changed

+54
-9
lines changed

README.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,6 @@ fn main() {
155155
### 4. point
156156

157157
```rust
158-
use synchronized::synchronized_point;
159-
use synchronized::synchronized;
160-
161158
/*
162159
An example implementation of synchronized code with
163160
one non-anonymous synchronization point.
@@ -166,8 +163,22 @@ use synchronized::synchronized;
166163
single named sync point. Each synchronization code executes in the same
167164
way as ordinary anonymous code, but execution occurs simultaneously in a
168165
multi-threaded environment in only one of them.
166+
167+
!!! In this example, the assembly requires the `point` feature to be active.
169168
*/
170169

170+
#[cfg( feature = "point" )]
171+
use synchronized::synchronized_point;
172+
#[cfg( feature = "point" )]
173+
use synchronized::synchronized;
174+
175+
#[cfg( not(feature = "point") )]
176+
macro_rules! synchronized_point {
177+
[ $($unk:tt)* ] => {
178+
println!("!!! This example requires support for the `point` feature. Run the example with `cargo run --example point --all-features`.");
179+
};
180+
}
181+
171182
fn main() {
172183
// A sync point named `COMB_SYNC` to group anonymous code syncs by name.
173184
synchronized_point! {(COMB_SYNC) {

examples/point.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11

2-
use synchronized::synchronized_point;
3-
use synchronized::synchronized;
4-
52
/*
63
An example implementation of synchronized code with
74
one non-anonymous synchronization point.
@@ -10,8 +7,22 @@ use synchronized::synchronized;
107
single named sync point. Each synchronization code executes in the same
118
way as ordinary anonymous code, but execution occurs simultaneously in a
129
multi-threaded environment in only one of them.
10+
11+
!!! In this example, the assembly requires the `point` feature to be active.
1312
*/
1413

14+
#[cfg( feature = "point" )]
15+
use synchronized::synchronized_point;
16+
#[cfg( feature = "point" )]
17+
use synchronized::synchronized;
18+
19+
#[cfg( not(feature = "point") )]
20+
macro_rules! synchronized_point {
21+
[ $($unk:tt)* ] => {
22+
println!("!!! This example requires support for the `point` feature. Run the example with `cargo run --example point --all-features`.");
23+
};
24+
}
25+
1526
fn main() {
1627
// A sync point named `COMB_SYNC` to group anonymous code syncs by name.
1728
synchronized_point! {(COMB_SYNC) {

examples/point_let.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
11

2+
#[cfg( feature = "point" )]
23
use synchronized::synchronized_point;
4+
#[cfg( feature = "point" )]
35
use synchronized::synchronized;
46

7+
58
/*
69
An example of the implementation of synchronized code with one non-anonymous (named)
710
synchronization point with one mutable variable.
11+
12+
!!! In this example, the assembly requires the `point` feature to be active.
813
*/
914

15+
#[cfg( not(feature = "point") )]
16+
macro_rules! synchronized_point {
17+
[ $($unk:tt)* ] => {
18+
println!("!!! This example requires support for the `point` feature. Run the example with `cargo run --example point_let --all-features`.");
19+
};
20+
}
21+
1022
fn main() {
1123
// A sync point named `COMB_SYNC` to group anonymous code syncs by name.
1224
//

src/lib.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,6 @@ fn main() {
168168
### 4. point
169169
170170
```rust
171-
use synchronized::synchronized_point;
172-
use synchronized::synchronized;
173-
174171
/*
175172
An example implementation of synchronized code with
176173
one non-anonymous synchronization point.
@@ -179,8 +176,22 @@ use synchronized::synchronized;
179176
single named sync point. Each synchronization code executes in the same
180177
way as ordinary anonymous code, but execution occurs simultaneously in a
181178
multi-threaded environment in only one of them.
179+
180+
!!! In this example, the assembly requires the `point` feature to be active.
182181
*/
183182
183+
#[cfg( feature = "point" )]
184+
use synchronized::synchronized_point;
185+
#[cfg( feature = "point" )]
186+
use synchronized::synchronized;
187+
188+
#[cfg( not(feature = "point") )]
189+
macro_rules! synchronized_point {
190+
[ $($unk:tt)* ] => {
191+
println!("!!! This example requires support for the `point` feature. Run the example with `cargo run --example point --all-features`.");
192+
};
193+
}
194+
184195
fn main() {
185196
// A sync point named `COMB_SYNC` to group anonymous code syncs by name.
186197
synchronized_point! {(COMB_SYNC) {

0 commit comments

Comments
 (0)