On Jul 1, 2011, at 12:04 PM, stef...@apache.org wrote:

> Author: stefan2
> Date: Fri Jul  1 19:04:29 2011
> New Revision: 1142026
> 
> URL: http://svn.apache.org/viewvc?rev=1142026&view=rev
> Log:
> Introduce the svn_mutex API and implement it
> 
> * subversion/include/private/svn_mutex.h
>  new private API header
> * subversion/libsvn_subr/svn_mutex.c
>  implement the new API
> 
> Added:
>    subversion/branches/svn_mutex/subversion/include/private/svn_mutex.h
>    subversion/branches/svn_mutex/subversion/libsvn_subr/svn_mutex.c
> 
> Added: subversion/branches/svn_mutex/subversion/include/private/svn_mutex.h
> URL: 
> http://svn.apache.org/viewvc/subversion/branches/svn_mutex/subversion/include/private/svn_mutex.h?rev=1142026&view=auto
> ==============================================================================
> --- subversion/branches/svn_mutex/subversion/include/private/svn_mutex.h 
> (added)
> +++ subversion/branches/svn_mutex/subversion/include/private/svn_mutex.h Fri 
> Jul  1 19:04:29 2011
> @@ -0,0 +1,82 @@
> +/**
> + * @copyright
> + * ====================================================================
> + *    Licensed to the Apache Software Foundation (ASF) under one
> + *    or more contributor license agreements.  See the NOTICE file
> + *    distributed with this work for additional information
> + *    regarding copyright ownership.  The ASF licenses this file
> + *    to you under the Apache License, Version 2.0 (the
> + *    "License"); you may not use this file except in compliance
> + *    with the License.  You may obtain a copy of the License at
> + *
> + *      http://www.apache.org/licenses/LICENSE-2.0
> + *
> + *    Unless required by applicable law or agreed to in writing,
> + *    software distributed under the License is distributed on an
> + *    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
> + *    KIND, either express or implied.  See the License for the
> + *    specific language governing permissions and limitations
> + *    under the License.
> + * ====================================================================
> + * @endcopyright
> + *
> + * @file svn_mutex.h
> + * @brief Strutures and functions for mutual exclusion
> + */
> +
> +#ifndef SVN_MUTEX_H
> +#define SVN_MUTEX_H
> +
> +#include <apr_thread_mutex.h>
> +#include "svn_error.h"
> +
> +#ifdef __cplusplus
> +extern "C" {
> +#endif /* __cplusplus */
> +
> +/**
> + * This is a simple wrapper around @c apr_thread_mutex_t and will be a
> + * valid identifier even if APR does not support threading.
> + */
> +typedef struct svn_mutex__t
> +{
> +#if APR_HAS_THREADS
> +
> +  /** A mutex for synchronization between threads. It may be NULL, in
> +   * which case no synchronization will take place. The latter is useful,
> +   * if implement some functionality where synchronization is optional.
> +   */
> +  apr_thread_mutex_t *mutex;
> +  
> +#endif
> +} svn_mutex__t;
> +
> +/** Initialize the @a *mutex with a lifetime defined by @a pool, if
> + * @a enable_mutex is TRUE and with @c NULL otherwise. If @a enable_mutex
> + * is set but threading is not supported by APR, this function returns an
> + * @c APR_ENOTIMPL error.

The NULL part is a little confusing, it took a couple of reads to see the NULL 
was associated with *mutex.  Suggest changing it so something like

/** If @a enable_mutex is TRUE, initialize the @a *mutex with a lifetime
  * defined by @a pool, otherwise initialize it with @c NULL.


How would we use enable_mutex?  Seems like a compile time constant, not a 
runtime one.

> + */
> +svn_error_t *
> +svn_mutex__init(svn_mutex__t *mutex,
> +                svn_boolean_t enable_mutex,
> +                apr_pool_t *pool);
> +
> +/** Acquire the @a mutex, if that has been enabled in @ref svn_mutex__init.
> + * Make sure to call @ref svn_mutex__unlock some time later in the same 
> + * thread to release the mutex again. Recursive locking are not supported.
> + */
> +svn_error_t *
> +svn_mutex__lock(svn_mutex__t mutex);
> +
> +/** Release the @a mutex, previously acquired using @ref svn_mutex__lock
> + * that has been enabled in @ref svn_mutex__init.
> + */
> +svn_error_t *
> +svn_mutex__unlock(svn_mutex__t mutex,
> +                  svn_error_t *err);

What is the input err for?

Blair

Reply via email to