1 // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 #![feature(generators, generator_trait)]
13 use std
::ops
::Generator
;
14 use std
::sync
::atomic
::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering}
;
16 static A
: AtomicUsize
= ATOMIC_USIZE_INIT
;
22 A
.fetch_add(1, Ordering
::SeqCst
);
27 fn test() -> bool { true }
28 fn test2() -> bool { false }
44 let n
= A
.load(Ordering
::SeqCst
);
45 unsafe { a.resume() }
;
46 assert_eq
!(A
.load(Ordering
::SeqCst
), n
+ 1);
47 unsafe { a.resume() }
;
48 assert_eq
!(A
.load(Ordering
::SeqCst
), n
+ 1);
60 let n
= A
.load(Ordering
::SeqCst
);
61 unsafe { a.resume() }
;
62 assert_eq
!(A
.load(Ordering
::SeqCst
), n
);
63 unsafe { a.resume() }
;
64 assert_eq
!(A
.load(Ordering
::SeqCst
), n
+ 1);