apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@apache.org
Subject cvs commit: apr/test testlock.c
Date Thu, 13 Sep 2001 01:04:23 GMT
rbb         01/09/12 18:04:23

  Modified:    .        CHANGES
               locks/beos Makefile.in
               locks/os2 Makefile.in
               locks/unix Makefile.in
               test     testlock.c
  Added:       include  apr_thread_cond.h
               include/arch/beos thread_cond.h
               include/arch/netware thread_cond.h
               include/arch/os2 thread_cond.h
               include/arch/unix thread_cond.h
               include/arch/win32 thread_cond.h
               locks/beos thread_cond.c
               locks/netware thread_cond.c
               locks/os2 thread_cond.c
               locks/unix thread_cond.c
               locks/win32 thread_cond.c
  Log:
  Add condition variables to the APR set of locking functions.
  This does Unix, and provides stubs for all other platforms.
  
  Submitted by:	Aaron Bannert <aaron@clove.org>
  
  Revision  Changes    Path
  1.155     +4 -0      apr/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/apr/CHANGES,v
  retrieving revision 1.154
  retrieving revision 1.155
  diff -u -r1.154 -r1.155
  --- CHANGES	2001/09/12 19:46:12	1.154
  +++ CHANGES	2001/09/13 01:04:22	1.155
  @@ -1,5 +1,9 @@
   Changes with APR b1  
   
  +  *) Add condition variables to the APR set of locking functions.
  +     This does Unix, and provides stubs for all other platforms.
  +     [Aaron Bannert <aaron@clove.org>]
  +
     *) Don't search for IPv6 names in apr_sockaddr_info_get() if the 
        application doesn't specify the family (i.e., the application
        passes in AF_UNSPEC) and APR isn't built with IPv6 support.  
  
  
  
  1.1                  apr/include/apr_thread_cond.h
  
  Index: apr_thread_cond.h
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  #ifndef APR_THREAD_COND_H
  #define APR_THREAD_COND_H
  
  #include "apr.h"
  #include "apr_pools.h"
  #include "apr_errno.h"
  #include "apr_thread_mutex.h"
  
  #ifdef __cplusplus
  extern "C" {
  #endif /* __cplusplus */
  
  /**
   * @file apr_thread_cond.h
   * @brief APR Condition Variable Routines
   */
  
  /**
   * @defgroup APR_Cond Condition Variable Routines
   * @ingroup APR
   * @{
   */
  
  typedef struct apr_thread_cond_t apr_thread_cond_t;
  
  /*   Function definitions */
  
  /**
   * Create and initialize a condition variable that can be used to signal
   * and schedule threads in a single process.
   * @param cond the memory address where the newly created condition variable
   *        will be stored.
   * @param pool the pool from which to allocate the mutex.
   */
  APR_DECLARE(apr_status_t) apr_thread_cond_create(apr_thread_cond_t **cond,
                                                   apr_pool_t *pool);
  /**
   * Put the active calling thread to sleep until signaled to wake up. Each
   * condition variable must be associated with a mutex, and that mutex must
   * be locked before  calling this function, or the behavior will be
   * undefined. As the calling thread is put to sleep, the given mutex
   * will be simultaneously released; and as this thread wakes up the lock
   * is again simultaneously acquired.
   * @param cond the condition variable on which to block.
   * @param mutex the mutex that must be locked upon entering this function,
   *        is released while the thread is asleep, and is again acquired before
   *        returning from this function.
   */
  APR_DECLARE(apr_status_t) apr_thread_cond_wait(apr_thread_cond_t *cond,
                                                 apr_thread_mutex_t *mutex);
  
  /* XXX: Should we add apr_thread_cond_timedwait()? Can it be done on all
   *      platforms? -aaron */
  
  /**
   * Signals a singla thread, if one exists, that is blocking on the given
   * condition variable. That thread is then scheduled to wake up and acquire
   * the associated mutex. Although it is not required, if predictible schedule
   * is desired, that mutex must be locked while calling this function.
   * @param cond the condition variable on which to produce the signal.
   */
  APR_DECLARE(apr_status_t) apr_thread_cond_signal(apr_thread_cond_t *cond);
  /**
   * Signals all threads blocking on the given condition variable.
   * Each thread that was signaled is then schedule to wake up and acquire
   * the associated mutex. This will happen in a serialized manner.
   * @param cond the condition variable on which to produce the broadcast.
   */
  APR_DECLARE(apr_status_t) apr_thread_cond_broadcast(apr_thread_cond_t *cond);
  
  /**
   * Destroy the condition variable and free the associated memory.
   * @param cond the condition variable to destroy.
   */
  APR_DECLARE(apr_status_t) apr_thread_cond_destroy(apr_thread_cond_t *cond);
  
  
  #ifdef __cplusplus
  }
  #endif
  
  #endif  /* ! APR_THREAD_COND_H */
  
  
  
  1.1                  apr/include/arch/beos/thread_cond.h
  
  Index: thread_cond.h
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  #ifndef THREAD_COND_H
  #define THREAD_COND_H
  
  #include <kernel/OS.h>
  #include "apr_pools.h"
  #include "apr_thread_cond.h"
  #include "apr_file_io.h"
  #include "apr_general.h"
  #include "apr_lib.h"
  #include "apr_portable.h"
  
  struct apr_thread_cond_t {
      apr_pool_t *pool;
  };
  
  #endif  /* THREAD_COND_H */
  
  
  
  
  1.1                  apr/include/arch/netware/thread_cond.h
  
  Index: thread_cond.h
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  #ifndef THREAD_COND_H
  #define THREAD_COND_H
  
  #include "apr_thread_cond.h"
  #include <nks/synch.h>
  
  struct apr_thread_cond_t {
      apr_pool_t *pool;
  };
  
  #endif  /* THREAD_COND_H */
  
  
  
  
  1.1                  apr/include/arch/os2/thread_cond.h
  
  Index: thread_cond.h
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  #ifndef THREAD_COND_H
  #define THREAD_COND_H
  
  #include "apr_thread_cond.h"
  #include "apr_file_io.h"
  
  struct apr_thread_cond_t {
      apr_pool_t *pool;
  };
  
  #endif  /* THREAD_COND_H */
  
  
  
  
  1.1                  apr/include/arch/unix/thread_cond.h
  
  Index: thread_cond.h
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  #ifndef THREAD_COND_H
  #define THREAD_COND_H
  
  #include "apr.h"
  #include "apr_private.h"
  #include "apr_general.h"
  #include "apr_lib.h"
  #include "apr_thread_mutex.h"
  #include "apr_thread_cond.h"
  #include "apr_pools.h"
  
  #if APR_HAVE_PTHREAD_H
  #include <pthread.h>
  #endif
  
  /* XXX: Should we have a better autoconf search, something like
   * APR_HAS_PTHREAD_COND? -aaron */
  #if APR_HAS_THREADS
  struct apr_thread_cond_t {
      apr_pool_t *pool;
      pthread_cond_t *cond;
  };
  #endif
  
  #endif  /* THREAD_COND_H */
  
  
  
  
  1.1                  apr/include/arch/win32/thread_cond.h
  
  Index: thread_cond.h
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  #ifndef THREAD_COND_H
  #define THREAD_COND_H
  
  #include "apr_thread_cond.h"
  
  struct apr_thread_cond_t {
      apr_pool_t *pool;
  };
  
  #endif  /* THREAD_COND_H */
  
  
  
  
  1.15      +2 -1      apr/locks/beos/Makefile.in
  
  Index: Makefile.in
  ===================================================================
  RCS file: /home/cvs/apr/locks/beos/Makefile.in,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- Makefile.in	2001/09/08 23:36:34	1.14
  +++ Makefile.in	2001/09/13 01:04:23	1.15
  @@ -1,7 +1,8 @@
   
   TARGETS = locks.lo \
   	thread_mutex.lo \
  -	thread_rwlock.lo
  +	thread_rwlock.lo \
  +	thread_cond.lo
   
   # bring in rules.mk for standard functionality
   @INCLUDE_RULES@
  
  
  
  1.1                  apr/locks/beos/thread_cond.c
  
  Index: thread_cond.c
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  /*Read/Write locking implementation based on the MultiLock code from
   * Stephen Beaulieu <hippo@be.com>
   */
   
  #include "beos/thread_mutex.h"
  #include "beos/thread_cond.h"
  #include "apr_strings.h"
  #include "apr_portable.h"
  
  
  APR_DECLARE(apr_status_t) apr_thread_cond_create(apr_thread_cond_t **cond,
                                                   apr_pool_t *pool)
  {
      return APR_ENOTIMPL;
  }
  
  APR_DECLARE(apr_status_t) apr_thread_cond_wait(apr_thread_cond_t *cond,
                                                 apr_thread_mutex_t *mutex)
  {
      return APR_ENOTIMPL;
  }
  
  APR_DECLARE(apr_status_t) apr_thread_cond_signal(apr_thread_cond_t *cond)
  {
      return APR_ENOTIMPL;
  }
  
  APR_DECLARE(apr_status_t) apr_thread_cond_broadcast(apr_thread_cond_t *cond)
  {
      return APR_ENOTIMPL;
  }
  
  APR_DECLARE(apr_status_t) apr_thread_cond_destroy(apr_thread_cond_t *cond)
  {
      return APR_ENOTIMPL;
  }
  
  
  
  1.1                  apr/locks/netware/thread_cond.c
  
  Index: thread_cond.c
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  #include "apr.h"
  #include "apr_private.h"
  #include "apr_general.h"
  #include "apr_strings.h"
  #include "thread_mutex.h"
  #include "thread_cond.h"
  #include "apr_portable.h"
  
  APR_DECLARE(apr_status_t) apr_thread_cond_create(apr_thread_cond_t **cond,
                                                   apr_pool_t *pool)
  {
      return APR_ENOTIMPL;
  }
  
  APR_DECLARE(apr_status_t) apr_thread_cond_wait(apr_thread_cond_t *cond,
                                                 apr_thread_mutex_t *mutex)
  {
      return APR_ENOTIMPL;
  }
  
  APR_DECLARE(apr_status_t) apr_thread_cond_signal(apr_thread_cond_t *cond)
  {
      return APR_ENOTIMPL;
  }
  
  APR_DECLARE(apr_status_t) apr_thread_cond_broadcast(apr_thread_cond_t *cond)
  {
      return APR_ENOTIMPL;
  }
  
  APR_DECLARE(apr_status_t) apr_thread_cond_destroy(apr_thread_cond_t *cond)
  {
      return APR_ENOTIMPL;
  }
  
  
  
  1.15      +2 -1      apr/locks/os2/Makefile.in
  
  Index: Makefile.in
  ===================================================================
  RCS file: /home/cvs/apr/locks/os2/Makefile.in,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- Makefile.in	2001/09/08 23:36:34	1.14
  +++ Makefile.in	2001/09/13 01:04:23	1.15
  @@ -1,7 +1,8 @@
   
   TARGETS = locks.lo \
   	thread_mutex.lo \
  -	thread_rwlock.lo
  +	thread_rwlock.lo \
  +	thread_cond.lo
   
   # bring in rules.mk for standard functionality
   @INCLUDE_RULES@
  
  
  
  1.1                  apr/locks/os2/thread_cond.c
  
  Index: thread_cond.c
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  #include "apr_general.h"
  #include "apr_lib.h"
  #include "apr_strings.h"
  #include "apr_portable.h"
  #include "thread_mutex.h"
  #include "thread_cond.h"
  #include "fileio.h"
  #include <string.h>
  
  APR_DECLARE(apr_status_t) apr_thread_cond_create(apr_thread_cond_t **cond,
                                                   apr_pool_t *pool)
  {
      return APR_ENOTIMPL;
  }
  
  APR_DECLARE(apr_status_t) apr_thread_cond_wait(apr_thread_cond_t *cond,
                                                 apr_thread_mutex_t *mutex)
  {
      return APR_ENOTIMPL;
  }
  
  APR_DECLARE(apr_status_t) apr_thread_cond_signal(apr_thread_cond_t *cond)
  {
      return APR_ENOTIMPL;
  }
  
  APR_DECLARE(apr_status_t) apr_thread_cond_broadcast(apr_thread_cond_t *cond)
  {
      return APR_ENOTIMPL;
  }
  
  APR_DECLARE(apr_status_t) apr_thread_cond_destroy(apr_thread_cond_t *cond)
  {
      return APR_ENOTIMPL;
  }
  
  
  
  1.21      +2 -1      apr/locks/unix/Makefile.in
  
  Index: Makefile.in
  ===================================================================
  RCS file: /home/cvs/apr/locks/unix/Makefile.in,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- Makefile.in	2001/09/08 23:36:34	1.20
  +++ Makefile.in	2001/09/13 01:04:23	1.21
  @@ -4,7 +4,8 @@
   	crossproc.lo \
   	intraproc.lo \
   	thread_mutex.lo \
  -	thread_rwlock.lo
  +	thread_rwlock.lo \
  +	thread_cond.lo
   
   # bring in rules.mk for standard functionality
   @INCLUDE_RULES@
  
  
  
  1.1                  apr/locks/unix/thread_cond.c
  
  Index: thread_cond.c
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  #include "thread_mutex.h"
  #include "thread_cond.h"
  
  #if APR_HAS_THREADS
  
  
  static apr_status_t thread_cond_cleanup(void *data)
  {
      apr_thread_cond_t *cond = (apr_thread_cond_t *)data;
      apr_status_t stat;
  
      stat = pthread_cond_destroy(cond->cond);
  #ifdef PTHREAD_SETS_ERRNO
      if (stat) {
          stat = errno;
      }
  #endif
      return stat;
  } 
  
  APR_DECLARE(apr_status_t) apr_thread_cond_create(apr_thread_cond_t **cond,
                                                   apr_pool_t *pool)
  {
      apr_thread_cond_t *new_cond;
      apr_status_t stat;
  
      new_cond = (apr_thread_cond_t *)apr_pcalloc(pool,
                                                  sizeof(apr_thread_cond_t));
  
      if (new_cond == NULL) {
          return APR_ENOMEM;
      }
  
      new_cond->pool = pool;
      new_cond->cond = (pthread_cond_t *)apr_palloc(pool, 
                                                    sizeof(pthread_cond_t));
  
      if (new_cond->cond == NULL) {
          return APR_ENOMEM;
      }
  
      if ((stat = pthread_cond_init(new_cond->cond, NULL))) {
  #ifdef PTHREAD_SETS_ERRNO
          stat = errno;
  #endif
          thread_cond_cleanup(new_cond);
          return stat;
      }
  
      apr_pool_cleanup_register(new_cond->pool,
                                (void *)new_cond, thread_cond_cleanup,
                                apr_pool_cleanup_null);
  
      *cond = new_cond;
      return APR_SUCCESS;
  }
  
  APR_DECLARE(apr_status_t) apr_thread_cond_wait(apr_thread_cond_t *cond,
                                                 apr_thread_mutex_t *mutex)
  {
      apr_status_t stat;
  
      stat = pthread_cond_wait(cond->cond, &mutex->mutex);
  #ifdef PTHREAD_SETS_ERRNO
      if (stat) {
          stat = errno;
      }
  #endif
      return stat;
  }
  
  APR_DECLARE(apr_status_t) apr_thread_cond_signal(apr_thread_cond_t *cond)
  {
      apr_status_t stat;
  
      stat = pthread_cond_signal(cond->cond);
  #ifdef PTHREAD_SETS_ERRNO
      if (stat) {
          stat = errno;
      }
  #endif
      return stat;
  }
  
  APR_DECLARE(apr_status_t) apr_thread_cond_broadcast(apr_thread_cond_t *cond)
  {
      apr_status_t stat;
  
      stat = pthread_cond_broadcast(cond->cond);
  #ifdef PTHREAD_SETS_ERRNO
      if (stat) {
          stat = errno;
      }
  #endif
      return stat;
  }
  
  APR_DECLARE(apr_status_t) apr_thread_cond_destroy(apr_thread_cond_t *cond)
  {
      apr_status_t stat;
      if ((stat = thread_cond_cleanup(cond)) == APR_SUCCESS) {
          apr_pool_cleanup_kill(cond->pool, cond, thread_cond_cleanup);
          return APR_SUCCESS;
      }
      return stat;
  }
  
  
  #endif /* APR_HAS_THREADS */
  
  
  
  1.1                  apr/locks/win32/thread_cond.c
  
  Index: thread_cond.c
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  #include "apr.h"
  #include "apr_private.h"
  #include "apr_general.h"
  #include "apr_strings.h"
  #include "win32/thread_mutex.h"
  #include "win32/thread_cond.h"
  #include "apr_portable.h"
  
  APR_DECLARE(apr_status_t) apr_thread_cond_create(apr_thread_cond_t **cond,
                                                   apr_pool_t *pool)
  {
      return APR_ENOTIMPL;
  }
  
  APR_DECLARE(apr_status_t) apr_thread_cond_wait(apr_thread_cond_t *cond,
                                                 apr_thread_mutex_t *mutex)
  {
      return APR_ENOTIMPL;
  }
  
  APR_DECLARE(apr_status_t) apr_thread_cond_signal(apr_thread_cond_t *cond)
  {
      return APR_ENOTIMPL;
  }
  
  APR_DECLARE(apr_status_t) apr_thread_cond_broadcast(apr_thread_cond_t *cond)
  {
      return APR_ENOTIMPL;
  }
  
  APR_DECLARE(apr_status_t) apr_thread_cond_destroy(apr_thread_cond_t *cond)
  {
      return APR_ENOTIMPL;
  }
  
  
  
  1.8       +143 -2    apr/test/testlock.c
  
  Index: testlock.c
  ===================================================================
  RCS file: /home/cvs/apr/test/testlock.c,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- testlock.c	2001/09/10 18:17:07	1.7
  +++ testlock.c	2001/09/13 01:04:23	1.8
  @@ -57,6 +57,7 @@
   #include "apr_lock.h"
   #include "apr_thread_mutex.h"
   #include "apr_thread_rwlock.h"
  +#include "apr_thread_cond.h"
   #include "apr_errno.h"
   #include "apr_general.h"
   #include "apr_getopt.h"
  @@ -75,14 +76,18 @@
   #else /* !APR_HAS_THREADS */
   
   #define MAX_ITER 40000
  +#define MAX_COUNTER 100000
   
   void * APR_THREAD_FUNC thread_rw_func(apr_thread_t *thd, void *data);
   void * APR_THREAD_FUNC thread_rwlock_func(apr_thread_t *thd, void *data);
   void * APR_THREAD_FUNC thread_function(apr_thread_t *thd, void *data);
   void * APR_THREAD_FUNC thread_mutex_function(apr_thread_t *thd, void *data);
  +void * APR_THREAD_FUNC thread_cond_producer(apr_thread_t *thd, void *data);
  +void * APR_THREAD_FUNC thread_cond_consumer(apr_thread_t *thd, void *data);
   apr_status_t test_exclusive(void);
   apr_status_t test_rw(void);
   apr_status_t test_multiple_locking(const char *);
  +apr_status_t test_cond(void);
   
   
   apr_file_t *in, *out, *err;
  @@ -92,6 +97,19 @@
   apr_pool_t *pool;
   int i = 0, x = 0;
   
  +int buff[MAX_COUNTER];
  +struct {
  +    apr_thread_mutex_t *mutex;
  +    int                nput;
  +    int                nval;
  +} put;
  +
  +struct {
  +    apr_thread_mutex_t *mutex;
  +    apr_thread_cond_t  *cond;
  +    int                nready;
  +} nready;
  +
   void * APR_THREAD_FUNC thread_rw_func(apr_thread_t *thd, void *data)
   {
       int exitLoop = 1;
  @@ -192,6 +210,49 @@
       return NULL;
   } 
   
  +void * APR_THREAD_FUNC thread_cond_producer(apr_thread_t *thd, void *data)
  +{
  +    for (;;) {
  +        apr_thread_mutex_lock(put.mutex);
  +        if (put.nput >= MAX_COUNTER) {
  +            apr_thread_mutex_unlock(put.mutex);
  +            return NULL;
  +        }
  +        buff[put.nput] = put.nval;
  +        put.nput++;
  +        put.nval++;
  +        apr_thread_mutex_unlock(put.mutex);
  +
  +        apr_thread_mutex_lock(nready.mutex);
  +        if (nready.nready == 0)
  +            apr_thread_cond_signal(nready.cond);
  +        nready.nready++;
  +        apr_thread_mutex_unlock(nready.mutex);
  +
  +        *((int *) data) += 1;
  +    }
  +
  +    return NULL;
  +}
  +
  +void * APR_THREAD_FUNC thread_cond_consumer(apr_thread_t *thd, void *data)
  +{
  +    int i;
  +
  +    for (i = 0; i < MAX_COUNTER; i++) {
  +        apr_thread_mutex_lock(nready.mutex);
  +        while (nready.nready == 0)
  +            apr_thread_cond_wait(nready.cond, nready.mutex);
  +        nready.nready--;
  +        apr_thread_mutex_unlock(nready.mutex);
  +
  +        if (buff[i] != i)
  +            printf("buff[%d] = %d\n", i, buff[i]);
  +    }
  +
  +    return NULL;
  +}
  +
   int test_rw(void)
   {
       apr_thread_t *t1, *t2, *t3, *t4;
  @@ -334,7 +395,7 @@
       return APR_SUCCESS;
   }
   
  -apr_status_t test_thread_mutex(void)
  +static apr_status_t test_thread_mutex(void)
   {
       apr_thread_t *t1, *t2, *t3, *t4;
       apr_status_t s1, s2, s3, s4;
  @@ -382,7 +443,7 @@
       return APR_SUCCESS;
   }
   
  -int test_thread_rwlock(void)
  +static int test_thread_rwlock(void)
   {
       apr_thread_t *t1, *t2, *t3, *t4;
       apr_status_t s1, s2, s3, s4;
  @@ -429,6 +490,80 @@
       return APR_SUCCESS;
   }
   
  +apr_status_t test_cond(void)
  +{
  +    apr_thread_t *p1, *p2, *p3, *p4, *c1;
  +    apr_status_t s0, s1, s2, s3, s4;
  +    int count1, count2, count3, count4;
  +    int sum;
  +
  +    printf("thread_cond Tests\n");
  +    printf("%-60s", "    Initializing the first apr_thread_mutex_t");
  +    s1 = apr_thread_mutex_create(&put.mutex, pool);
  +    if (s1 != APR_SUCCESS) {
  +        printf("Failed!\n");
  +        return s1;
  +    }
  +    printf("OK\n");
  +
  +    printf("%-60s", "    Initializing the second apr_thread_mutex_t");
  +    s1 = apr_thread_mutex_create(&nready.mutex, pool);
  +    if (s1 != APR_SUCCESS) {
  +        printf("Failed!\n");
  +        return s1;
  +    }
  +    printf("OK\n");
  +
  +    printf("%-60s", "    Initializing the apr_thread_cond_t");
  +    s1 = apr_thread_cond_create(&nready.cond, pool);
  +    if (s1 != APR_SUCCESS) {
  +        printf("Failed!\n");
  +        return s1;
  +    }
  +    printf("OK\n");
  +
  +    count1 = count2 = count3 = count4 = 0;
  +    put.nput = put.nval = 0;
  +    nready.nready = 0;
  +    i = 0;
  +    x = 0;
  +
  +    printf("%-60s","    Starting all the threads"); 
  +    s0 = apr_thread_create(&p1, NULL, thread_cond_producer, &count1, pool);
  +    s1 = apr_thread_create(&p2, NULL, thread_cond_producer, &count2, pool);
  +    s2 = apr_thread_create(&p3, NULL, thread_cond_producer, &count3, pool);
  +    s3 = apr_thread_create(&p4, NULL, thread_cond_producer, &count4, pool);
  +    s4 = apr_thread_create(&c1, NULL, thread_cond_consumer, NULL, pool);
  +    if (s0 != APR_SUCCESS || s1 != APR_SUCCESS || s2 != APR_SUCCESS || 
  +        s3 != APR_SUCCESS || s4 != APR_SUCCESS) {
  +        printf("Failed!\n");
  +        return s1;
  +    }
  +    printf("OK\n");
  +
  +    printf("%-60s", "    Waiting for threads to exit");
  +    apr_thread_join(&s0, p1);
  +    apr_thread_join(&s1, p2);
  +    apr_thread_join(&s2, p3);
  +    apr_thread_join(&s3, p4);
  +    apr_thread_join(&s4, c1);
  +    printf("OK\n");
  +
  +    sum = count1 + count2 + count3 + count4;
  +    /*
  +    printf("count1 = %d count2 = %d count3 = %d count4 = %d\n",
  +            count1, count2, count3, count4);
  +    */
  +    if (sum != MAX_COUNTER) {
  +        fprintf(stderr, "thread_cond didn't work as expected. sum = %d, instead of %d\n", sum, MAX_COUNTER);
  +    }
  +    else {
  +        printf("Test passed\n");
  +    }
  +    
  +    return APR_SUCCESS;
  +}
  +
   int main(int argc, const char * const *argv)
   {
       apr_status_t rv;
  @@ -492,6 +627,12 @@
           fprintf(stderr,"thread_rwlock test failed : [%d] %s\n",
                   rv, apr_strerror(rv, (char*)errmsg, 200));
           exit(-6);
  +    }
  +
  +    if ((rv = test_cond()) != APR_SUCCESS) {
  +        fprintf(stderr,"thread_cond test failed : [%d] %s\n",
  +                rv, apr_strerror(rv, (char*)errmsg, 200));
  +        exit(-7);
       }
   
       return 0;
  
  
  

Mime
View raw message