Last change
on this file since b28ce93 was 3483185, checked in by kyoung <lseo@…>, 7 months ago |
Make it possible to fulfil a future by loading an exception like ucpp
|
-
Property mode
set to
100644
|
File size:
776 bytes
|
Line | |
---|
1 | #include <fstream.hfa>
|
---|
2 | #include <thread.hfa>
|
---|
3 | #include <locks.hfa>
|
---|
4 | #include <future.hfa>
|
---|
5 |
|
---|
6 | ExceptionDecl(E);
|
---|
7 |
|
---|
8 | semaphore L;
|
---|
9 |
|
---|
10 | thread A{ future( int ) & F; };
|
---|
11 | void ?{}( A & this, future( int ) & F) {
|
---|
12 | &this.F = &F;
|
---|
13 | }
|
---|
14 | thread B{ future( int ) & F; };
|
---|
15 | void ?{}( B & this, future( int ) & F) {
|
---|
16 | &this.F = &F;
|
---|
17 | }
|
---|
18 |
|
---|
19 | void main( A & this ) {
|
---|
20 | sout | "A: loading F with E";
|
---|
21 | this.F( ExceptionPtr( ExceptionInst( E ) ) );
|
---|
22 | P( L );
|
---|
23 | reset( this.F );
|
---|
24 | }
|
---|
25 |
|
---|
26 | void main( B & this ) {
|
---|
27 | try {
|
---|
28 | waituntil( this.F ) {
|
---|
29 | enable_ehm();
|
---|
30 | int f = this.F();
|
---|
31 | checked_poll();
|
---|
32 | sout|"B: should not be printed! " | f;
|
---|
33 | disable_ehm();
|
---|
34 | }
|
---|
35 | } catch( E * ) {
|
---|
36 | sout | "B: caught E";
|
---|
37 | V( L );
|
---|
38 | }
|
---|
39 | }
|
---|
40 |
|
---|
41 | int main(){
|
---|
42 | future( int ) F;
|
---|
43 | processor p;
|
---|
44 | for( 10 ) {
|
---|
45 | L{0};
|
---|
46 | B b={ F };
|
---|
47 | A a={ F };
|
---|
48 | }
|
---|
49 | return 0;
|
---|
50 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.