[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: APR feature idea: named global mutex retrieval

From: Philip Martin <philip_at_codematters.co.uk>
Date: 2005-04-16 14:32:45 CEST

Greg Hudson <ghudson@MIT.EDU> writes:

> My idea is to provide an APR interface like:
>
> apr_status_t apr_thread_mutex_get_named(apr_thread_mutex_t **mutex,
> const char *name);
>
> which would create or fetch from a global hash table a mutex by name.
> APR can use a mutex (presumably one created by apr_initialize) to
> serialize access to the hash table.
>
> Do people think this is a reasonable feature, or have other ideas for
> how to solve this sort of problem?

The obvious answer on a POSIX like system is to allow static
initialisation of mutexes, this would probably have to be a separate
type and not an apr_thread_mutex_t. I don't know whether such a thing
is possible on Windows, it's absence from APR suggests not.

The other answer on a POSIX system is a thread-once function. APR
provides these but they suffer the same problem as APR's mutexes--they
don't support static initialisation.

A variant to your named mutex idea would be to use a similar method to
provide a thread-once interface that didn't require dynamic
initialisation. This would still require a global hash table, to hold
function addresses in this case, but might require fewer mutexes. Of
course it's likely that the thread-once functions would be used to
create mutexes so this may not be much of a saving.

-- 
Philip Martin
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sat Apr 16 14:33:30 2005

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.