Last change
on this file since 6f47834 was
3bf9d10,
checked in by Peter A. Buhr <pabuhr@…>, 17 months ago
|
change printf to sout
|
-
Property mode set to
100644
|
File size:
981 bytes
|
Line | |
---|
1 | // Try cancelling a thread. |
---|
2 | |
---|
3 | #include <fstream.hfa> |
---|
4 | #include <thread.hfa> |
---|
5 | |
---|
6 | exception internal_error {}; |
---|
7 | vtable(internal_error) internal_vt; |
---|
8 | |
---|
9 | thread WillCancel {}; |
---|
10 | |
---|
11 | const char * msg(ThreadCancelled(WillCancel) * this) { |
---|
12 | return "ThreadCancelled(WillCancel)"; |
---|
13 | } |
---|
14 | |
---|
15 | void main(WillCancel &) { |
---|
16 | sout | '1'; |
---|
17 | cancel_stack((internal_error){&internal_vt}); |
---|
18 | sout | '!'; |
---|
19 | } |
---|
20 | |
---|
21 | void explicit() { |
---|
22 | try { |
---|
23 | sout | '0'; |
---|
24 | WillCancel cancel; |
---|
25 | sout | '1'; |
---|
26 | join(cancel); |
---|
27 | sout | '4'; |
---|
28 | } catchResume (ThreadCancelled(WillCancel) * error) { |
---|
29 | sout | '2'; |
---|
30 | if ((virtual internal_error *)error->the_exception) { |
---|
31 | sout | '3'; |
---|
32 | } |
---|
33 | } |
---|
34 | sout | '5' | nl; |
---|
35 | } |
---|
36 | |
---|
37 | void implicit() { |
---|
38 | try { |
---|
39 | { |
---|
40 | sout | '0'; |
---|
41 | WillCancel cancel; |
---|
42 | sout | '1'; |
---|
43 | } |
---|
44 | sout | '4'; |
---|
45 | } catchResume (ThreadCancelled(WillCancel) * error) { |
---|
46 | sout | '2'; |
---|
47 | if ((virtual internal_error *)error->the_exception) { |
---|
48 | sout | '3'; |
---|
49 | } |
---|
50 | } |
---|
51 | sout | '5' | nl; |
---|
52 | } |
---|
53 | |
---|
54 | int main(int argc, char * argv[]) { |
---|
55 | sout | nlOff; |
---|
56 | explicit(); |
---|
57 | implicit(); |
---|
58 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.