source: src/tests/thread.c @ 4a3334cf

aaron-thesisarm-ehcleanup-dtorsdeferred_resndemanglerjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerresolv-newwith_gc
Last change on this file since 4a3334cf was 4a3334cf, checked in by Thierry Delisle <tdelisle@…>, 5 years ago

Fixed tests after rename

  • Property mode set to 100644
File size: 847 bytes
Line 
1#include <fstream>
2#include <kernel>
3#include <stdlib>
4#include <thread>
5
6struct First { thread t; signal_once* lock; };
7struct Second { thread t; signal_once* lock; };
8
9DECL_THREAD(First);
10DECL_THREAD(Second);
11
12void ?{}( First * this, signal_once* lock ) { this->lock = lock; }
13void ?{}( Second * this, signal_once* lock ) { this->lock = lock; }
14
15void main(First* this) {
16        for(int i = 0; i < 10; i++) {
17                sout | "First : Suspend No." | i + 1 | endl;
18                yield();
19        }
20        signal(this->lock);
21}
22
23void main(Second* this) {
24        wait(this->lock);
25        for(int i = 0; i < 10; i++) {
26                sout | "Second : Suspend No." | i + 1 | endl;
27                yield();
28        }
29}
30
31
32int main(int argc, char* argv[]) {
33        signal_once lock;
34        sout | "User main begin" | endl;
35        {
36                processor p;
37                {
38                        scoped(First)  f = { &lock };
39                        scoped(Second) s = { &lock };
40                }
41        }
42        sout | "User main end" | endl;
43}
Note: See TracBrowser for help on using the repository browser.