Go to the documentation of this file.00001
00002
00003 #include "ace/Thread.h"
00004
00005 ACE_RCSID(ace,
00006 Thread,
00007 "$Id: Thread.cpp 84163 2009-01-15 07:57:27Z johnnyw $")
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 const char* thr_name[])
00027 {
00028 ACE_TRACE ("ACE_Thread::spawn_n");
00029 size_t i;
00030
00031 for (i = 0; i < n; i++)
00032 {
00033 ACE_thread_t t_id;
00034
00035 if (ACE_OS::thr_create (func,
00036 arg,
00037 flags,
00038 &t_id,
00039 0,
00040 priority,
00041 stack == 0 ? 0 : stack[i],
00042 stack_size == 0 ? ACE_DEFAULT_THREAD_STACKSIZE : stack_size[i],
00043 thread_adapter,
00044 thr_name == 0 ? 0 : &thr_name[i]) != 0)
00045 break;
00046 }
00047
00048 return i;
00049 }
00050
00051 size_t
00052 ACE_Thread::spawn_n (ACE_thread_t thread_ids[],
00053 size_t n,
00054 ACE_THR_FUNC func,
00055 void *arg,
00056 long flags,
00057 long priority,
00058 void *stack[],
00059 size_t stack_size[],
00060 ACE_hthread_t thread_handles[],
00061 ACE_Thread_Adapter *thread_adapter,
00062 const char* thr_name[])
00063 {
00064 ACE_TRACE ("ACE_Thread::spawn_n");
00065 size_t i = 0;
00066
00067 for (i = 0; i < n; i++)
00068 {
00069 ACE_thread_t t_id;
00070 ACE_hthread_t t_handle;
00071
00072 int const result =
00073 ACE_OS::thr_create (func,
00074 arg,
00075 flags,
00076 &t_id,
00077 &t_handle,
00078 priority,
00079 stack == 0 ? 0 : stack[i],
00080 stack_size == 0 ? ACE_DEFAULT_THREAD_STACKSIZE : stack_size[i],
00081 thread_adapter,
00082 thr_name == 0 ? 0 : &thr_name[i]);
00083
00084 if (result == 0)
00085 {
00086 if (thread_ids != 0)
00087 thread_ids[i] = t_id;
00088 if (thread_handles != 0)
00089 thread_handles[i] = t_handle;
00090 }
00091 else
00092
00093 break;
00094 }
00095
00096 return i;
00097 }
00098
00099 ACE_END_VERSIONED_NAMESPACE_DECL
00100
00101 #endif