Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
Main Page
Related Pages
Topics
Namespaces
Data Structures
Files
File List
Globals
EXTERNAL_HEADERS
RSL
etc
config
src
THREAD_SAFE_EXCEPTIONS.cpp
Go to the documentation of this file.
1
// checking if exceptions are thread safe
2
3
25
#include "
thread.h
"
26
#include "
nodbg.h
"
27
28
29
extern
"C"
void
*
thread_proc
(
void
*
arg
)
30
{
31
long
sum = 0;
32
long
n
= (
char
*)
arg
- (
char
*)0;
33
34
for
(
long
i
= 0;
i
!= 0x20000; ++
i
) {
35
try
{
36
if
(
i
% 2 ==
n
)
37
throw
i
;
38
else
39
throw
arg
;
40
}
41
catch
(
long
) {
42
++sum;
43
}
44
catch
(...) {
45
sum += 2;
46
}
47
}
48
49
return
(
void
*)sum;
50
}
51
52
53
int
main
()
54
{
55
nodbg
();
56
57
pthread_t tid [2];
58
59
const
unsigned
N
=
sizeof
tid /
sizeof
*tid;
60
61
set_concurrency
(
N
);
62
63
unsigned
i
;
64
65
for
(
i
= 0;
i
!=
N
; ++
i
)
66
if
(pthread_create (tid +
i
, 0,
thread_proc
, (
void
*)
i
))
67
return
1;
68
69
for
(
i
= 0;
i
!=
N
; ++
i
)
70
pthread_join (tid [
i
], 0);
71
72
return
0;
73
}
N
#define N
Definition
17.names.cpp:157
i
#define i
Definition
17.names.cpp:126
n
#define n
Definition
17.names.cpp:130
thread_proc
void * thread_proc(void *arg)
Definition
THREAD_SAFE_EXCEPTIONS.cpp:29
main
int main()
Definition
THREAD_SAFE_EXCEPTIONS.cpp:53
nodbg.h
nodbg
void nodbg()
Definition
nodbg.h:52
thread.h
set_concurrency
#define set_concurrency(n)
Definition
thread.h:103
arg
int arg
Definition
locale.cpp:2806
Generated by
1.9.8