apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Lucian Adrian Grijincu" <lucian.griji...@gmail.com>
Subject Re: New Vista APIs
Date Sun, 14 Jan 2007 04:47:40 GMT
the two cond_wait functions in APR:
apr_thread_cond_wait(apr_thread_cond_t *cond, apr_thread_mutex_t *mutex) and
apr_thread_cond_timedwait (apr_thread_cond_t *cond, apr_thread_mutex_t
*mutex, apr_interval_time_t timeout)

use a apr_thread_mutex_t as the object being unlocked.

the new condition variable form Vista unlocks either a CriticalSection
or a SRWLock object (SleepConditionVariableCS and

the win32 implementation for apr_thread_mutex_t on Vista uses either
Events or CriticalSections depending on weather
APR_THREAD_MUTEX_UNNESTED was specified when the lock was constructed
or not.

We can't just use the new calls on Vista because we can't atomically
"release" an event and sleep on the condition variable.

Because of this we'll need a new constructor
apr_thread_cond_create2 (apr_thread_cond_t **cond,
                                          apr_int32_t * flag,
                                          apr_pool_t * pool)

and have the developer specify which kind of lock he's going to use
with this lock.
If he chooses to use APR_THREAD_MUTEX_UNNESTED locks, we'll revert to
the current implementation. If he guarantees he won't use these kind
of locks we can freely use the new Condition variables.

anyways, my former question stands: how would you like apr to deal
with this issue: have a secondary constructor, or have a new set of
objects (or just forget about it)?

PS: on vista systems we can also modify apr_thread_lock_t to use
SRWLocks in exclusive mode instead of CriticalSections.

some coverage about the new synchronization APIs from Vista here:

On 1/6/07, Garrett Rooney <rooneg@electricjellyfish.net> wrote:
> On 1/6/07, Lucian Adrian Grijincu <lucian.grijincu@gmail.com> wrote:
> Considering the number of complaints that people have had with our
> condition variable implementation on win32 over the years, I think an
> implementation in terms of a native win32 condition variable API would
> probably be a good thing, even if it's vista-only and won't be
> practically usable for many people for quite some time.
> -garrett

Lucian Adrian Grijincu

View raw message