apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "William A. Rowe, Jr." <wr...@rowe-clan.net>
Subject Re: New Vista APIs
Date Mon, 15 Jan 2007 09:25:32 GMT
Lucian Adrian Grijincu wrote:
>> Maybe a create flag APR_TRYLOCK_MAY_BLOCK?
> I was thinking more in the realm of APR_TRYLOCK_WILL_FAIL:
> a.) WILL because we'd want a similar behavior on all platforms
> (portability, no?). If we use this API
>        on Vista we'll either block or return an error (APR_EINVAL ...
> invalid apr_thread_rwlock_t
>        used with the _trylock function). The code must behave the same
> on unices and the rest.
> b.) FAIL because blocking:
>         1) is harder to implement than a return error :)
>         2) violates the contract of the _trylock function

No, because we won't GUARANTEE it to fail, because we would refuse to add
processing cycles to determine if the flag was used where it is unneeded
and offers no performance boost.  We also have no desire to fail the
call to create, either.  Let it proceed...

This is an optimization that allows rwlock to choose a mechanism that
offers no trylock, but still allows it to use a mechanism that would
support trylock.  The difference is, the platform uses the most efficient
method, and adds cpu cycles for the logic, only if it pays off as a WIN
on that platform.

Optimizations aren't supposed to penalize other platforms.

View raw message