apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wr...@apache.org
Subject cvs commit: apr/threadproc/win32 thread.c
Date Tue, 24 Jul 2001 05:16:32 GMT
wrowe       01/07/23 22:16:32

  Modified:    .        CHANGES
               include  apr_thread_proc.h
               include/arch/beos threadproc.h
               include/arch/os2 threadproc.h
               include/arch/unix threadproc.h
               include/arch/win32 threadproc.h
               threadproc/beos thread.c
               threadproc/os2 thread.c
               threadproc/unix thread.c
               threadproc/win32 thread.c
  Log:
    Updated APR to pass the thread worker_function prototype
    (apr_thread_start_t) two parameters, the apr private data
    (apr_thread_t*) and the application private data (void*).
    Applications' worker_thread() routines may use apr_thread_pool_get
    to access the pool (implemented using APR_POOL_*_ACCESSOR() macros.)
  
  Submitted by:	Aaron Bannert <aaron@ebuilt.com>
  Reviewed by:	Will Rowe
  
  Revision  Changes    Path
  1.126     +7 -0      apr/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/apr/CHANGES,v
  retrieving revision 1.125
  retrieving revision 1.126
  diff -u -r1.125 -r1.126
  --- CHANGES	2001/07/24 03:02:58	1.125
  +++ CHANGES	2001/07/24 05:16:32	1.126
  @@ -1,5 +1,12 @@
   Changes with APR b1  
   
  +  *) Updated APR to pass the thread worker_function prototype 
  +     (apr_thread_start_t) two parameters, the apr private data 
  +     (apr_thread_t*) and the application private data (void*).  
  +     Applications' worker_thread() routines may use apr_thread_pool_get
  +     to access the pool (implemented using APR_POOL_*_ACCESSOR() macros.)
  +     [Aaron Bannert <aaron@ebuilt.com>]
  +
     *) Add Solaris 8's sendfilev() support.  This requires the following 
        patches from Sun: 111297 (Sparc), 111298 (x86).  You'll need the
        other patches listed in the patch description.  [Justin Erenkrantz]
  
  
  
  1.66      +12 -1     apr/include/apr_thread_proc.h
  
  Index: apr_thread_proc.h
  ===================================================================
  RCS file: /home/cvs/apr/include/apr_thread_proc.h,v
  retrieving revision 1.65
  retrieving revision 1.66
  diff -u -r1.65 -r1.66
  --- apr_thread_proc.h	2001/06/06 18:11:06	1.65
  +++ apr_thread_proc.h	2001/07/24 05:16:32	1.66
  @@ -125,7 +125,10 @@
   typedef struct apr_other_child_rec_t  apr_other_child_rec_t;
   #endif /* APR_HAS_OTHER_CHILD */
   
  -typedef void *(APR_THREAD_FUNC *apr_thread_start_t)(void *);
  +/**
  + * The prototype for any APR thread worker functions.
  + */
  +typedef void *(APR_THREAD_FUNC *apr_thread_start_t)(apr_thread_t*, void*);
   
   enum kill_conditions {
       kill_never,                 /* process is never sent any signals */
  @@ -599,6 +602,14 @@
    * apr_status_t apr_signal_thread((int)(*signal_handler)(int signum))
    */
   APR_DECLARE(apr_status_t) apr_signal_thread(int(*signal_handler)(int signum));
  +
  +/**
  + * Get the child-pool used by the thread from the thread info.
  + * @return apr_pool_t the pool
  + * @deffunc apr_pool_t apr_thread_info_pool_get(apr_thread_info_t *i)
  + */
  +APR_POOL_DECLARE_ACCESSOR(thread);
  +
   #endif /* APR_HAS_THREADS */
   
   #ifdef __cplusplus
  
  
  
  1.18      +2 -0      apr/include/arch/beos/threadproc.h
  
  Index: threadproc.h
  ===================================================================
  RCS file: /home/cvs/apr/include/arch/beos/threadproc.h,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- threadproc.h	2001/02/16 04:15:49	1.17
  +++ threadproc.h	2001/07/24 05:16:32	1.18
  @@ -80,6 +80,8 @@
   struct apr_thread_t {
       apr_pool_t *cntxt;
       thread_id td;
  +    void *data;
  +    apr_thread_start_t func;
   };
   
   struct apr_threadattr_t {
  
  
  
  1.10      +0 -2      apr/include/arch/os2/threadproc.h
  
  Index: threadproc.h
  ===================================================================
  RCS file: /home/cvs/apr/include/arch/os2/threadproc.h,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- threadproc.h	2001/02/16 04:15:50	1.9
  +++ threadproc.h	2001/07/24 05:16:32	1.10
  @@ -95,7 +95,5 @@
       apr_int32_t detached;
   };
   
  -typedef void (*os2_thread_start_t)(void *);
  -
   #endif  /* ! THREAD_PROC_H */
   
  
  
  
  1.19      +2 -0      apr/include/arch/unix/threadproc.h
  
  Index: threadproc.h
  ===================================================================
  RCS file: /home/cvs/apr/include/arch/unix/threadproc.h,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- threadproc.h	2001/04/11 02:01:18	1.18
  +++ threadproc.h	2001/07/24 05:16:32	1.19
  @@ -90,6 +90,8 @@
   struct apr_thread_t {
       apr_pool_t *cntxt;
       pthread_t *td;
  +    void *data;
  +    apr_thread_start_t func;
   };
   
   struct apr_threadattr_t {
  
  
  
  1.14      +2 -0      apr/include/arch/win32/threadproc.h
  
  Index: threadproc.h
  ===================================================================
  RCS file: /home/cvs/apr/include/arch/win32/threadproc.h,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- threadproc.h	2001/02/16 04:15:52	1.13
  +++ threadproc.h	2001/07/24 05:16:32	1.14
  @@ -66,6 +66,8 @@
       HANDLE td;
       apr_int32_t cancel;
       apr_int32_t cancel_how;
  +    void *data;
  +    apr_thread_start_t func;
   };
   
   struct apr_threadattr_t {
  
  
  
  1.23      +11 -1     apr/threadproc/beos/thread.c
  
  Index: thread.c
  ===================================================================
  RCS file: /home/cvs/apr/threadproc/beos/thread.c,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- thread.c	2001/06/14 18:52:05	1.22
  +++ thread.c	2001/07/24 05:16:32	1.23
  @@ -88,6 +88,12 @@
   	return APR_NOTDETACH;
   }
   
  +void *dummy_worker(void *opaque)
  +{
  +    apr_thread_t *thd = (apr_thread_t*)opaque;
  +    return thd->func(thd, thd->data);
  +}
  +
   apr_status_t apr_thread_create(apr_thread_t **new, apr_threadattr_t *attr,
                                apr_thread_start_t func, void *data,
                                apr_pool_t *cont)
  @@ -101,6 +107,8 @@
       }
   
       (*new)->cntxt = cont;
  +    (*new)->data = data;
  +    (*new)->func = func;
   
       /* First we create the new thread...*/
   	if (attr)
  @@ -113,7 +121,7 @@
           return stat;
       }
   
  -    (*new)->td = spawn_thread((thread_func)func, "apr thread", temp, data);
  +    (*new)->td = spawn_thread((thread_func)dummy_func, "apr thread", temp, (*new));
       /* Now we try to run it...*/
       if (resume_thread((*new)->td) == B_NO_ERROR) {
           return APR_SUCCESS;
  @@ -191,3 +199,5 @@
       (*thd)->td = *thethd;
       return APR_SUCCESS;
   }
  +
  +APR_POOL_IMPLEMENT_ACCESSOR_X(thread, cntxt)
  
  
  
  1.23      +6 -8      apr/threadproc/os2/thread.c
  
  Index: thread.c
  ===================================================================
  RCS file: /home/cvs/apr/threadproc/os2/thread.c,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- thread.c	2001/06/16 01:27:15	1.22
  +++ thread.c	2001/07/24 05:16:32	1.23
  @@ -95,7 +95,7 @@
   static void apr_thread_begin(void *arg)
   {
     apr_thread_t *thread = (apr_thread_t *)arg;
  -  thread->rv = thread->func(thread->data);
  +  thread->rv = thread->func(thread, thread->data);
   }
   
   
  @@ -131,13 +131,9 @@
               return stat;
           }
       }
  -    
  -    if (thread->attr->attr & APR_THREADATTR_DETACHED)
  -        thread->tid = _beginthread((os2_thread_start_t)func, NULL, 
  -                                   APR_THREAD_STACKSIZE, data);
  -    else
  -        thread->tid = _beginthread(apr_thread_begin, NULL, 
  -                                   APR_THREAD_STACKSIZE, thread);
  +
  +    thread->tid = _beginthread(apr_thread_begin, NULL, 
  +                               APR_THREAD_STACKSIZE, thread);
           
       if (thread->tid < 0) {
           return errno;
  @@ -235,3 +231,5 @@
   {
       return apr_pool_userdata_set(data, key, cleanup, thread->cntxt);
   }
  +
  +APR_POOL_IMPLEMENT_ACCESSOR_X(thread, cntxt)
  
  
  
  1.40      +14 -3     apr/threadproc/unix/thread.c
  
  Index: thread.c
  ===================================================================
  RCS file: /home/cvs/apr/threadproc/unix/thread.c,v
  retrieving revision 1.39
  retrieving revision 1.40
  diff -u -r1.39 -r1.40
  --- thread.c	2001/06/14 18:52:09	1.39
  +++ thread.c	2001/07/24 05:16:32	1.40
  @@ -116,6 +116,12 @@
       return APR_NOTDETACH;
   }
   
  +void *dummy_worker(void *opaque)
  +{
  +    apr_thread_t *thread = (apr_thread_t*)opaque;
  +    return thread->func(thread, thread->data);
  +}
  +
   apr_status_t apr_thread_create(apr_thread_t **new, apr_threadattr_t *attr, 
                                apr_thread_start_t func, void *data, 
                                apr_pool_t *cont)
  @@ -136,18 +142,20 @@
       }
   
       (*new)->cntxt = cont;
  -
  +    (*new)->data = data;
  +    (*new)->func = func;
  +    
       if (attr)
           temp = attr->attr;
       else
           temp = NULL;
  -    
  +
       stat = apr_pool_create(&(*new)->cntxt, cont);
       if (stat != APR_SUCCESS) {
           return stat;
       }
   
  -    if ((stat = pthread_create((*new)->td, temp, func, data)) == 0) {
  +    if ((stat = pthread_create((*new)->td, temp, dummy_worker, (*new))) == 0) {
           return APR_SUCCESS;
       }
       else {
  @@ -240,6 +248,9 @@
       (*thd)->td = thethd;
       return APR_SUCCESS;
   }
  +
  +APR_POOL_IMPLEMENT_ACCESSOR_X(thread, cntxt)
  +
   #endif  /* HAVE_PTHREAD_H */
   #endif  /* APR_HAS_THREADS */
   
  
  
  
  1.33      +11 -2     apr/threadproc/win32/thread.c
  
  Index: thread.c
  ===================================================================
  RCS file: /home/cvs/apr/threadproc/win32/thread.c,v
  retrieving revision 1.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- thread.c	2001/07/06 14:20:03	1.32
  +++ thread.c	2001/07/24 05:16:32	1.33
  @@ -89,6 +89,12 @@
       return APR_NOTDETACH;
   }
   
  +void *dummy_func(void *opaque)
  +{
  +    apr_thread_t *thd = (apr_thread_t *)opaque;
  +    return thd->func(thd, thd->data);
  +}
  +
   APR_DECLARE(apr_status_t) apr_thread_create(apr_thread_t **new,
                                               apr_threadattr_t *attr,
                                               apr_thread_start_t func,
  @@ -105,6 +111,8 @@
       }
   
       (*new)->cntxt = cont;
  +    (*new)->data = data;
  +    (*new)->func = func;
       
       stat = apr_pool_create(&(*new)->cntxt, cont);
       if (stat != APR_SUCCESS) {
  @@ -114,8 +122,8 @@
       /* Use 0 for Thread Stack Size, because that will default the stack to the
        * same size as the calling thread. 
        */
  -    if (((*new)->td = (HANDLE *)_beginthreadex(NULL, 0, (unsigned int (APR_THREAD_FUNC
*)(void *))func,
  -                                               data, 0, &temp)) == 0) {
  +    if (((*new)->td = (HANDLE *)_beginthreadex(NULL, 0, (unsigned int (APR_THREAD_FUNC
*)(void *))dummy_func,
  +                                               (*new), 0, &temp)) == 0) {
           lasterror = apr_get_os_error();
           return APR_EEXIST; 
           /* MSVC++ doc doesn't mention any additional error info 
  @@ -207,3 +215,4 @@
       return APR_SUCCESS;
   }
   
  +APR_POOL_IMPLEMENT_ACCESSOR_X(thread, cntxt)
  
  
  

Mime
View raw message