00001
00002
00003 #include "ace/Thread.h"
00004
00005 ACE_RCSID(ace,
00006 Thread,
00007 "Thread.cpp,v 4.12 2006/04/06 19:14:26 jwillemsen Exp")
00008
00009 #if !defined (__ACE_INLINE__)
00010 #include "ace/Thread.inl"
00011 #endif
00012
00013 #if defined (ACE_HAS_THREADS)
00014
00015 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00016
00017 size_t
00018 ACE_Thread::spawn_n (size_t n,
00019 ACE_THR_FUNC func,
00020 void *arg,
00021 long flags,
00022 long priority,
00023 void *stack[],
00024 size_t stack_size[],
00025 ACE_Thread_Adapter *thread_adapter)
00026 {
00027 ACE_TRACE ("ACE_Thread::spawn_n");
00028 ACE_thread_t t_id;
00029 size_t i;
00030
00031 for (i = 0; i < n; i++)
00032
00033 if (ACE_OS::thr_create (func,
00034 arg,
00035 flags,
00036 &t_id,
00037 0,
00038 priority,
00039 stack == 0 ? 0 : stack[i],
00040 stack_size == 0 ? 0 : stack_size[i],
00041 thread_adapter) != 0)
00042 break;
00043
00044 return i;
00045 }
00046
00047 size_t
00048 ACE_Thread::spawn_n (ACE_thread_t thread_ids[],
00049 size_t n,
00050 ACE_THR_FUNC func,
00051 void *arg,
00052 long flags,
00053 long priority,
00054 void *stack[],
00055 size_t stack_size[],
00056 ACE_hthread_t thread_handles[],
00057 ACE_Thread_Adapter *thread_adapter)
00058 {
00059 ACE_TRACE ("ACE_Thread::spawn_n");
00060 size_t i;
00061
00062 for (i = 0; i < n; i++)
00063 {
00064 ACE_thread_t t_id;
00065 ACE_hthread_t t_handle;
00066
00067 int result =
00068 ACE_OS::thr_create (func,
00069 arg,
00070 flags,
00071 &t_id,
00072 &t_handle,
00073 priority,
00074 stack == 0 ? 0 : stack[i],
00075 stack_size == 0 ? 0 : stack_size[i],
00076 thread_adapter);
00077
00078 if (result == 0)
00079 {
00080 if (thread_ids != 0)
00081 thread_ids[i] = t_id;
00082 if (thread_handles != 0)
00083 thread_handles[i] = t_handle;
00084 }
00085 else
00086
00087 break;
00088 }
00089
00090 return i;
00091 }
00092
00093 ACE_END_VERSIONED_NAMESPACE_DECL
00094
00095 #endif