Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [BUG] zsystem:34: flock: invalid timeout value: '0'
On Sat, Jun 27, 2020 at 9:14 AM Cedric Ware
<cedric.ware__bml@xxxxxxxxxxxxxx> wrote:
>
> I didn't want to allow specifying a timeout below 1 microsecond,
> because that's the granularity of zsleep(). One could still allow it
> but silently treat it as 0.
Timeout strictly between 0 and 1 microsecond is not much different
from timeout between 1 and 2 microseconds. You can either round up or
down in both cases. Rounding up is the right thing to do for sleeps
and timeouts because it allows you to provide a guarantee.
For sleep (pseudo code):
time start = now();
if (sleep(duration) != INTERRUPTED)
assert(now - start() >= duration);
For anything with a timeout (pseudo code):
time start = now();
if (do_with_timeout(duration) == TIMEDOUT)
assert(now - start() >= duration);
If you round down, there is no non-trivial assertion that is
guaranteed to hold and that doesn't expose the internal granularity of
the duration.
Roman.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author