Thread.cpp

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

Generated on Tue Feb 2 17:18:43 2010 for ACE by  doxygen 1.4.7