[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Poor lockBeforeDate: implementation
From: |
Adam Fedor |
Subject: |
Re: Poor lockBeforeDate: implementation |
Date: |
Thu, 17 Jul 2003 09:35:08 -0600 |
On Thursday, July 17, 2003, at 08:54 AM, Richard Frith-Macdonald wrote:
I was looking at this code, and it fairly horribly retries at 1 second
intervals. There is an old comment in there that it uses sleep(),
(which has a 1 second granularity) because usleep() is 'not thread
safe under all architectures'
Does anyone know if this is actually true for the architectures we
actually support?
I'd like to rewrite this code to use [NSThread+sleepUntilDate:] (which
I have just updated to use nanosleep() if availalble) to start
sleeping for very small intervals, (perhaps starting with a
millisecond) increasing up to a maximum of 1 second intervals. That
should make a big increase in responsiveness of applications using
lockBeforeDate: ... but I don't want to do it if it will break things
because the sleep mechanism used is not thread safe in some way.
I've heard that usleep does not work well on Solaris, but Solaris has
nanosleep, so if you use that in preference, then it should be ok.