Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

Thread.cpp

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

Generated on Mon Jun 16 11:21:45 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002