apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dr...@apache.org
Subject cvs commit: apr/include/arch/beos threadproc.h
Date Tue, 11 Sep 2001 13:33:39 GMT
dreid       01/09/11 06:33:39

  Modified:    threadproc/beos proc.c thread.c threadpriv.c
               include/arch/beos threadproc.h
  Log:
  Tidy up to get us working again...
  
  - add the thread_once stuff (cribbed from OS/2 - thanks Brian)
  - correct the return values we get from threads
  - change thread_join to return the correct value
  
  Revision  Changes    Path
  1.39      +1 -0      apr/threadproc/beos/proc.c
  
  Index: proc.c
  ===================================================================
  RCS file: /home/cvs/apr/threadproc/beos/proc.c,v
  retrieving revision 1.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- proc.c	2001/08/10 21:04:48	1.38
  +++ proc.c	2001/09/11 13:33:39	1.39
  @@ -256,6 +256,7 @@
       if ( newproc < B_NO_ERROR) {
           return errno;
       }
  +
       resume_thread(newproc);
   
       if (attr->child_in) {
  
  
  
  1.27      +45 -3     apr/threadproc/beos/thread.c
  
  Index: thread.c
  ===================================================================
  RCS file: /home/cvs/apr/threadproc/beos/thread.c,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- thread.c	2001/08/10 21:04:48	1.26
  +++ thread.c	2001/09/11 13:33:39	1.27
  @@ -144,17 +144,19 @@
   APR_DECLARE(apr_status_t) apr_thread_exit(apr_thread_t *thd, apr_status_t *retval)
   {
       apr_pool_destroy(thd->cntxt);
  -	exit_thread ((status_t)retval);
  +	exit_thread ((status_t)(*retval));
   	return APR_SUCCESS;
   }
   
   APR_DECLARE(apr_status_t) apr_thread_join(apr_status_t *retval, apr_thread_t *thd)
   {
  -    if (wait_for_thread(thd->td,(void *)&retval) == B_NO_ERROR) {
  +    status_t rv = 0, ret;
  +    if ((ret = wait_for_thread(thd->td,&rv)) == B_NO_ERROR) {
  +        *retval = rv;
           return APR_SUCCESS;
       }
       else {
  -        return errno;
  +        return ret;
       }
   }
   
  @@ -201,6 +203,46 @@
           (*thd)->cntxt = cont;
       }
       (*thd)->td = *thethd;
  +    return APR_SUCCESS;
  +}
  +
  +static apr_status_t thread_once_cleanup(void *vcontrol)
  +{
  +    apr_thread_once_t *control = (apr_thread_once_t *)vcontrol;
  +
  +    if (control->sem) {
  +        release_sem(control->sem);
  +        delete_sem(control->sem);
  +    }
  +
  +    return APR_SUCCESS;
  +}
  +
  +APR_DECLARE(apr_status_t) apr_thread_once_init(apr_thread_once_t **control,
  +                                               apr_pool_t *p)
  +{
  +    int rc;
  +    *control = (apr_thread_once_t *)apr_pcalloc(p, sizeof(apr_thread_once_t));
  +    (*control)->hit = 0; /* we haven't done it yet... */
  +    rc = ((*control)->sem = create_sem(1, "thread_once"));
  +    if (rc != 0) {
  +        return rc;
  +    }
  +    apr_pool_cleanup_register(p, control, thread_once_cleanup, apr_pool_cleanup_null);
  +    return APR_SUCCESS;
  +}
  +
  +
  +
  +APR_DECLARE(apr_status_t) apr_thread_once(apr_thread_once_t *control, 
  +                                          void (*func)(void))
  +{
  +    if (!control->hit) {
  +        if (acquire_sem(control->sem) == B_OK) {
  +            control->hit = 1;
  +            func();
  +        }
  +    }
       return APR_SUCCESS;
   }
   
  
  
  
  1.18      +1 -1      apr/threadproc/beos/threadpriv.c
  
  Index: threadpriv.c
  ===================================================================
  RCS file: /home/cvs/apr/threadproc/beos/threadpriv.c,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- threadpriv.c	2001/08/10 21:04:48	1.17
  +++ threadpriv.c	2001/09/11 13:33:39	1.18
  @@ -117,7 +117,7 @@
   APR_DECLARE(apr_status_t) apr_threadkey_private_set(void *priv, apr_threadkey_t *key)
   {
   	thread_id tid;
  -	int i,index = 0, ret;
  +	int i,index = 0, ret = 0;
   
   	tid = find_thread(NULL);	
   	for (i=0; i < BEOS_MAX_DATAKEYS; i++){
  
  
  
  1.19      +5 -0      apr/include/arch/beos/threadproc.h
  
  Index: threadproc.h
  ===================================================================
  RCS file: /home/cvs/apr/include/arch/beos/threadproc.h,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- threadproc.h	2001/07/24 05:16:32	1.18
  +++ threadproc.h	2001/09/11 13:33:39	1.19
  @@ -123,5 +123,10 @@
       apr_int32_t detached;
   };
   
  +struct apr_thread_once_t {
  +    sem_id sem;
  +    int hit;
  +};
  +
   #endif  /* ! THREAD_PROC_H */
   
  
  
  

Mime
View raw message