1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
// $Id$
#include "ace/Thread.h"
ACE_RCSID(ace,
Thread,
"$Id$")
#if !defined (__ACE_INLINE__)
#include "ace/Thread.inl"
#endif /* !defined (__ACE_INLINE__) */
#if defined (ACE_HAS_THREADS)
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
size_t
ACE_Thread::spawn_n (size_t n,
ACE_THR_FUNC func,
void *arg,
long flags,
long priority,
void *stack[],
size_t stack_size[],
ACE_Thread_Adapter *thread_adapter)
{
ACE_TRACE ("ACE_Thread::spawn_n");
ACE_thread_t t_id;
size_t i;
for (i = 0; i < n; i++)
// Bail out if error occurs.
if (ACE_OS::thr_create (func,
arg,
flags,
&t_id,
0,
priority,
stack == 0 ? 0 : stack[i],
stack_size == 0 ? ACE_DEFAULT_THREAD_STACKSIZE : stack_size[i],
thread_adapter) != 0)
break;
return i;
}
size_t
ACE_Thread::spawn_n (ACE_thread_t thread_ids[],
size_t n,
ACE_THR_FUNC func,
void *arg,
long flags,
long priority,
void *stack[],
size_t stack_size[],
ACE_hthread_t thread_handles[],
ACE_Thread_Adapter *thread_adapter)
{
ACE_TRACE ("ACE_Thread::spawn_n");
size_t i;
for (i = 0; i < n; i++)
{
ACE_thread_t t_id;
ACE_hthread_t t_handle;
int result =
ACE_OS::thr_create (func,
arg,
flags,
&t_id,
&t_handle,
priority,
stack == 0 ? 0 : stack[i],
stack_size == 0 ? ACE_DEFAULT_THREAD_STACKSIZE : stack_size[i],
thread_adapter);
if (result == 0)
{
if (thread_ids != 0)
thread_ids[i] = t_id;
if (thread_handles != 0)
thread_handles[i] = t_handle;
}
else
// Bail out if error occurs.
break;
}
return i;
}
ACE_END_VERSIONED_NAMESPACE_DECL
#endif /* ACE_HAS_THREADS */
|