is_sorted() indeed. Mis-wrote that.
Sequencing multiple is_sorted() calls like you suggest may be done;
the race condition recurs as you allow access to the 'sorted' flag
outside the critical section, yet this time the inner is_sorted()
check prevents repeating the sort in case of race. Nice idea to cut
down on lock()/unlock() call pairs once the stack is already sorted a
while ago in time. Basically, this produces the safety needed without
extra overhead. I like it. :-)
Ger
On Fri, Nov 28, 2008 at 6:39 PM, Maarten Litmaath
<[EMAIL PROTECTED]> wrote:
> Ger Hobbelt wrote:
>
>> lock(l);
>> if ( ! is_locked())
>> {
>> sort();
>> sorted=1;
>> }
>> unlock(l);
>
> I suspect is_locked() needs to be is_sorted()?
>
> I suggest this instead:
>
> ----------------------------------------------
> if ( ! is_sorted()) {
> lock(l);
> if ( ! is_sorted())
> {
> sort();
> sorted=1;
> }
> unlock(l);
> }
> ----------------------------------------------
>
--
Met vriendelijke groeten / Best regards,
Ger Hobbelt
--------------------------------------------------
web: http://www.hobbelt.com/
http://www.hebbut.net/
mail: [EMAIL PROTECTED]
mobile: +31-6-11 120 978
--------------------------------------------------
______________________________________________________________________
OpenSSL Project http://www.openssl.org
Development Mailing List [email protected]
Automated List Manager [EMAIL PROTECTED]