@@ -12,6 +12,7 @@ fn broadcast_global() {
1212}
1313
1414#[ test]
15+ #[ cfg_attr( any( target_os = "emscripten" , target_family = "wasm" ) , ignore) ]
1516fn spawn_broadcast_global ( ) {
1617 let ( tx, rx) = crossbeam_channel:: unbounded ( ) ;
1718 crate :: spawn_broadcast ( move |ctx| tx. send ( ctx. index ( ) ) . unwrap ( ) ) ;
@@ -22,13 +23,15 @@ fn spawn_broadcast_global() {
2223}
2324
2425#[ test]
26+ #[ cfg_attr( any( target_os = "emscripten" , target_family = "wasm" ) , ignore) ]
2527fn broadcast_pool ( ) {
2628 let pool = ThreadPoolBuilder :: new ( ) . num_threads ( 7 ) . build ( ) . unwrap ( ) ;
2729 let v = pool. broadcast ( |ctx| ctx. index ( ) ) ;
2830 assert ! ( v. into_iter( ) . eq( 0 ..7 ) ) ;
2931}
3032
3133#[ test]
34+ #[ cfg_attr( any( target_os = "emscripten" , target_family = "wasm" ) , ignore) ]
3235fn spawn_broadcast_pool ( ) {
3336 let ( tx, rx) = crossbeam_channel:: unbounded ( ) ;
3437 let pool = ThreadPoolBuilder :: new ( ) . num_threads ( 7 ) . build ( ) . unwrap ( ) ;
@@ -40,13 +43,15 @@ fn spawn_broadcast_pool() {
4043}
4144
4245#[ test]
46+ #[ cfg_attr( any( target_os = "emscripten" , target_family = "wasm" ) , ignore) ]
4347fn broadcast_self ( ) {
4448 let pool = ThreadPoolBuilder :: new ( ) . num_threads ( 7 ) . build ( ) . unwrap ( ) ;
4549 let v = pool. install ( || crate :: broadcast ( |ctx| ctx. index ( ) ) ) ;
4650 assert ! ( v. into_iter( ) . eq( 0 ..7 ) ) ;
4751}
4852
4953#[ test]
54+ #[ cfg_attr( any( target_os = "emscripten" , target_family = "wasm" ) , ignore) ]
5055fn spawn_broadcast_self ( ) {
5156 let ( tx, rx) = crossbeam_channel:: unbounded ( ) ;
5257 let pool = ThreadPoolBuilder :: new ( ) . num_threads ( 7 ) . build ( ) . unwrap ( ) ;
@@ -58,6 +63,7 @@ fn spawn_broadcast_self() {
5863}
5964
6065#[ test]
66+ #[ cfg_attr( any( target_os = "emscripten" , target_family = "wasm" ) , ignore) ]
6167fn broadcast_mutual ( ) {
6268 let count = AtomicUsize :: new ( 0 ) ;
6369 let pool1 = ThreadPoolBuilder :: new ( ) . num_threads ( 3 ) . build ( ) . unwrap ( ) ;
@@ -73,6 +79,7 @@ fn broadcast_mutual() {
7379}
7480
7581#[ test]
82+ #[ cfg_attr( any( target_os = "emscripten" , target_family = "wasm" ) , ignore) ]
7683fn spawn_broadcast_mutual ( ) {
7784 let ( tx, rx) = crossbeam_channel:: unbounded ( ) ;
7885 let pool1 = Arc :: new ( ThreadPoolBuilder :: new ( ) . num_threads ( 3 ) . build ( ) . unwrap ( ) ) ;
@@ -90,6 +97,7 @@ fn spawn_broadcast_mutual() {
9097}
9198
9299#[ test]
100+ #[ cfg_attr( any( target_os = "emscripten" , target_family = "wasm" ) , ignore) ]
93101fn broadcast_mutual_sleepy ( ) {
94102 let count = AtomicUsize :: new ( 0 ) ;
95103 let pool1 = ThreadPoolBuilder :: new ( ) . num_threads ( 3 ) . build ( ) . unwrap ( ) ;
@@ -108,6 +116,7 @@ fn broadcast_mutual_sleepy() {
108116}
109117
110118#[ test]
119+ #[ cfg_attr( any( target_os = "emscripten" , target_family = "wasm" ) , ignore) ]
111120fn spawn_broadcast_mutual_sleepy ( ) {
112121 let ( tx, rx) = crossbeam_channel:: unbounded ( ) ;
113122 let pool1 = Arc :: new ( ThreadPoolBuilder :: new ( ) . num_threads ( 3 ) . build ( ) . unwrap ( ) ) ;
@@ -130,6 +139,7 @@ fn spawn_broadcast_mutual_sleepy() {
130139}
131140
132141#[ test]
142+ #[ cfg_attr( not( panic = "unwind" ) , ignore) ]
133143fn broadcast_panic_one ( ) {
134144 let count = AtomicUsize :: new ( 0 ) ;
135145 let pool = ThreadPoolBuilder :: new ( ) . num_threads ( 7 ) . build ( ) . unwrap ( ) ;
@@ -146,6 +156,7 @@ fn broadcast_panic_one() {
146156}
147157
148158#[ test]
159+ #[ cfg_attr( not( panic = "unwind" ) , ignore) ]
149160fn spawn_broadcast_panic_one ( ) {
150161 let ( tx, rx) = crossbeam_channel:: unbounded ( ) ;
151162 let ( panic_tx, panic_rx) = crossbeam_channel:: unbounded ( ) ;
@@ -166,6 +177,7 @@ fn spawn_broadcast_panic_one() {
166177}
167178
168179#[ test]
180+ #[ cfg_attr( not( panic = "unwind" ) , ignore) ]
169181fn broadcast_panic_many ( ) {
170182 let count = AtomicUsize :: new ( 0 ) ;
171183 let pool = ThreadPoolBuilder :: new ( ) . num_threads ( 7 ) . build ( ) . unwrap ( ) ;
@@ -182,6 +194,7 @@ fn broadcast_panic_many() {
182194}
183195
184196#[ test]
197+ #[ cfg_attr( not( panic = "unwind" ) , ignore) ]
185198fn spawn_broadcast_panic_many ( ) {
186199 let ( tx, rx) = crossbeam_channel:: unbounded ( ) ;
187200 let ( panic_tx, panic_rx) = crossbeam_channel:: unbounded ( ) ;
@@ -202,6 +215,7 @@ fn spawn_broadcast_panic_many() {
202215}
203216
204217#[ test]
218+ #[ cfg_attr( any( target_os = "emscripten" , target_family = "wasm" ) , ignore) ]
205219fn broadcast_sleep_race ( ) {
206220 let test_duration = time:: Duration :: from_secs ( 1 ) ;
207221 let pool = ThreadPoolBuilder :: new ( ) . num_threads ( 7 ) . build ( ) . unwrap ( ) ;
@@ -214,3 +228,35 @@ fn broadcast_sleep_race() {
214228 } ) ;
215229 }
216230}
231+
232+ #[ test]
233+ fn broadcast_after_spawn_broadcast ( ) {
234+ let ( tx, rx) = crossbeam_channel:: unbounded ( ) ;
235+
236+ // Queue a non-blocking spawn_broadcast.
237+ crate :: spawn_broadcast ( move |ctx| tx. send ( ctx. index ( ) ) . unwrap ( ) ) ;
238+
239+ // This blocking broadcast runs after all prior broadcasts.
240+ crate :: broadcast ( |_| { } ) ;
241+
242+ // The spawn_broadcast **must** have run by now on all threads.
243+ let mut v: Vec < _ > = rx. try_iter ( ) . collect ( ) ;
244+ v. sort_unstable ( ) ;
245+ assert ! ( v. into_iter( ) . eq( 0 ..crate :: current_num_threads( ) ) ) ;
246+ }
247+
248+ #[ test]
249+ fn broadcast_after_spawn ( ) {
250+ let ( tx, rx) = crossbeam_channel:: bounded ( 1 ) ;
251+
252+ // Queue a regular spawn on a thread-local deque.
253+ crate :: registry:: in_worker ( move |_, _| {
254+ crate :: spawn ( move || tx. send ( 22 ) . unwrap ( ) ) ;
255+ } ) ;
256+
257+ // Broadcast runs after the local deque is empty.
258+ crate :: broadcast ( |_| { } ) ;
259+
260+ // The spawn **must** have run by now.
261+ assert_eq ! ( 22 , rx. try_recv( ) . unwrap( ) ) ;
262+ }
0 commit comments