summaryrefslogtreecommitdiff
path: root/ace/Thread.cpp
blob: ad3cffca16eb298e778c9edc590fb7d27bda9e7a (plain)
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
// Thread.cpp
// $Id$

#define ACE_BUILD_DLL
#include "ace/Thread.h"

#if !defined (__ACE_INLINE__)
#include "ace/Thread.i"
#endif /* !defined (__ACE_INLINE__) */

#if defined (ACE_HAS_THREADS)

int
ACE_Thread::spawn_n (size_t n, 
		     ACE_THR_FUNC func, 
		     void *arg, 
		     long flags, 
		     u_int priority,
		     void *stack[], 
		     size_t stack_size[])
{
  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 ? 0 : stack_size[i]) != 0)
      break;

  return i;
}

int
ACE_Thread::spawn_n (ACE_thread_t thread_ids[],
		     size_t n, 
		     ACE_THR_FUNC func, 
		     void *arg, 
		     long flags, 
		     u_int priority,
		     void **stack,
		     size_t stack_size[])
{
  ACE_TRACE ("ACE_Thread::spawn_n");
  size_t i;

  for (i = 0; i < n; i++)
    {
      ACE_thread_t t_id;

      int result = ACE_OS::thr_create 
        (func, arg, flags, &t_id, 0, priority,
         stack == 0 ? 0 : stack[i], 
         stack_size == 0 ? 0 : stack_size[i]);

      if (result == 0)
	thread_ids[i] = t_id;
      else
        // Bail out if error occurs.
        break;
    }

  return i;
}

#endif /* ACE_HAS_THREADS */