You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by Justin Erenkrantz <je...@ebuilt.com> on 2001/04/28 06:33:00 UTC

Reader/writer locks?

Are reader/writer locks implemented in APR?

In include/apr_lock.h:

typedef enum {APR_MUTEX, APR_READWRITE} apr_locktype_e;

I don't see any use of apr_locktype_e in APR (besides the definition
in the apr_lock_t structure).  Are we just waiting for someone to 
implement APR_READWRITE?  Is everything right now essentially acting
as APR_MUTEX (regardless of what you pass in)?

It'd require a new apr_lock_acquire function in apr_locks.h...  I can 
probably implement this for POSIX-compliant systems - I don't have a 
clue for other architectures.  -- justin


Re: Reader/writer locks?

Posted by Greg Stein <gs...@lyra.org>.
On Fri, Apr 27, 2001 at 09:33:00PM -0700, Justin Erenkrantz wrote:
> Are reader/writer locks implemented in APR?

We have reader/writer locks on files, but not "freestanding" locks.

Let's say that you have an apr_file_t handy. You can then arbitrate access
to it using the apr_file_lock() and apr_file_unlock() functions.

> In include/apr_lock.h:
> 
> typedef enum {APR_MUTEX, APR_READWRITE} apr_locktype_e;
> 
> I don't see any use of apr_locktype_e in APR (besides the definition
> in the apr_lock_t structure).  Are we just waiting for someone to 
> implement APR_READWRITE?  Is everything right now essentially acting
> as APR_MUTEX (regardless of what you pass in)?

As Ryan mentioned, that stuff is pending somebody implementing them. I
almost tossed them a while back since it is misleading to keep them there.
Somebody say "don't" and I didn't bother to push it.

Cheers,
-g

-- 
Greg Stein, http://www.lyra.org/

Re: Reader/writer locks?

Posted by Justin Erenkrantz <je...@ebuilt.com>.
On Sat, Apr 28, 2001 at 08:14:35AM -0700, rbb@covalent.net wrote:
> 
> They are waiting for somebody to have the time to implement them.

I have a patch in my local tree to implement POSIX pthread rwlocks.

Basically adds to apr_lock.h:

typedef enum {APR_READER, APR_WRITER} apr_readerwriterlock_e;

/**
 * Lock a region with either a reader or writer lock.
 * @param lock The lock to set.
 * @param type The type of lock to acquire.
 * @deffunc apr_status_t apr_lock_acquire_rw(apr_lock_t *lock, apr_readerwriterlock_e type)
 */
APR_DECLARE(apr_status_t) apr_lock_acquire_rw(apr_lock_t *lock,
                                              apr_readerwriterlock_e type);

I am testing it now since I'm playing with threading ab.  This is a lark, 
but I'm REALLY frustrated at ab right now - even if this attempt at 
threading falls flat on its face, I can at least implement reader/writer 
locks in APR.

Whenever I finish it, I'll clean it up and post it.  I'll try and include 
the stubs for the other platforms.  -- justin


Re: Reader/writer locks?

Posted by rb...@covalent.net.
They are waiting for somebody to have the time to implement them.

Ryan

On Fri, 27 Apr 2001, Justin Erenkrantz wrote:

> Are reader/writer locks implemented in APR?
>
> In include/apr_lock.h:
>
> typedef enum {APR_MUTEX, APR_READWRITE} apr_locktype_e;
>
> I don't see any use of apr_locktype_e in APR (besides the definition
> in the apr_lock_t structure).  Are we just waiting for someone to
> implement APR_READWRITE?  Is everything right now essentially acting
> as APR_MUTEX (regardless of what you pass in)?
>
> It'd require a new apr_lock_acquire function in apr_locks.h...  I can
> probably implement this for POSIX-compliant systems - I don't have a
> clue for other architectures.  -- justin
>
>


_______________________________________________________________________________
Ryan Bloom                        	rbb@apache.org
406 29th St.
San Francisco, CA 94131
-------------------------------------------------------------------------------