Subject | Hash | Author | Date (UTC) |
---|---|---|---|
siplify example | d3f446eed13921445fd6f16f345e50e873a245e8 | mucbuc | 2020-01-24 14:44:36 |
Edited README.md | c4daca7870daa3a2bcc3cb3a56353b075feeea83 | mark | 2020-01-21 05:25:32 |
Edited README.md | dd5ec0c9fb495adc91a3446c6029e10cbca50741 | mark | 2020-01-21 05:23:48 |
Edited README.md | 7b965f28e6800858cb7250e4a838a11d99aa9146 | mark | 2020-01-21 05:22:23 |
README.md | b04ce36a75a1cc03f592f498320bcbd2487391e3 | Ubuntu | 2020-01-21 05:17:29 |
stack example | 10c89c204a6c7173da4cab531b023e49b43b282f | Ubuntu | 2020-01-21 05:10:05 |
rename namespace | 58de02fbcccc180ddbd895c03fe7615d85079fc2 | mucbuc | 2020-01-19 12:06:11 |
cleanup | 5ffc59ee2057db41384465ada3ce02da94928d83 | mucbuc | 2020-01-19 11:48:09 |
fixed swap | e79678e9a0f6c401bf6c75c073b4afb1d9c99239 | mucbuc | 2020-01-16 12:33:51 |
add unlock | ed0dd962bd7e1468faa3f74a6d61c6ba94b8db13 | mucbuc | 2020-01-12 16:43:19 |
documentaoion | 731b8bf31861113f070ee9e3613fdfbaef1e70a6 | mucbuc | 2020-01-12 15:46:29 |
index.h | 74aafab338206a3d3c02b7448852dbde831692dc | mucbuc | 2020-01-12 04:42:02 |
factory returns shared_ptr | 0d8ff1b381e3c7e275ebd99705853f54b100cdf9 | mucbuc | 2020-01-12 04:05:15 |
init | 01daaea5899ac77acb8ec0c15583573d78eb9f31 | mucbuc | 2020-01-12 03:10:36 |
File | Lines added | Lines deleted |
---|---|---|
README.md | 11 | 14 |
test/src/example.cpp | 5 | 16 |
File README.md changed (mode: 100644) (index e8b6529..55b7421) | |||
... | ... | namespace circuit { | |
24 | 24 | ||
25 | 25 | ## Example | ## Example |
26 | 26 | ``` | ``` |
27 | #include <tmp/src/test.h> | ||
28 | |||
29 | #include <lib/circuit/src/index.h> | ||
30 | |||
27 | 31 | using namespace std; | using namespace std; |
28 | 32 | using namespace om636::circuit; | using namespace om636::circuit; |
29 | 33 | ||
30 | 34 | int main() | int main() |
31 | 35 | { | { |
32 | 36 | CircuitStack<int> s; | CircuitStack<int> s; |
33 | auto t = thread([&]() { | ||
34 | int i(0); | ||
35 | s.wait_pop(i); | ||
36 | cout << "popped: " << i << endl; | ||
37 | s.push(88); | ||
38 | s.push(77); | ||
39 | }); | ||
40 | |||
41 | s.push(99); | ||
42 | t.join(); | ||
43 | |||
44 | int i(0); | ||
45 | while (s.check_pop(i)) { | ||
46 | cout << "popped: " << i << endl; | ||
37 | |||
38 | s.push(88); | ||
39 | s.push(77); | ||
40 | |||
41 | s.wait_pop(i); | ||
42 | if (s.check_pop(i)) { | ||
43 | |||
47 | 44 | } | } |
48 | 45 | } | } |
49 | 46 | ``` | ``` |
File test/src/example.cpp changed (mode: 100644) (index 5fba1be..5afe92a) | |||
1 | #include <iostream> | ||
2 | #include <thread> | ||
3 | |||
4 | 1 | #include <tmp/src/test.h> | #include <tmp/src/test.h> |
5 | 2 | ||
6 | 3 | #include <lib/circuit/src/index.h> | #include <lib/circuit/src/index.h> |
... | ... | int main() | |
12 | 9 | { | { |
13 | 10 | CircuitStack<int> s; | CircuitStack<int> s; |
14 | 11 | ||
15 | auto t = thread([&]() { | ||
16 | int i(0); | ||
17 | s.wait_pop(i); | ||
18 | cout << "popped: " << i << endl; | ||
19 | s.push(88); | ||
20 | s.push(77); | ||
21 | }); | ||
22 | |||
23 | s.push(99); | ||
24 | t.join(); | ||
12 | s.push(88); | ||
13 | s.push(77); | ||
25 | 14 | ||
26 | int i(0); | ||
27 | while (s.check_pop(i)) { | ||
28 | cout << "popped: " << i << endl; | ||
15 | s.wait_pop(i); | ||
16 | if (s.check_pop(i)) { | ||
17 | |||
29 | 18 | } | } |
30 | 19 | } | } |