receiveTimeout minimum reasonable timeout value?
JR via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu May 15 13:21:41 PDT 2014
On Thursday, 15 May 2014 at 18:15:46 UTC, Charles Hixson via
Digitalmars-d-learn wrote:
> Duration can be specified in nanoseconds, but does it make any
> sense
> to have a value of 1 nanosecond? 0?
>
> My desire is to check whether a message is in the queue, and
> then
> either move it local to the thread, or continue, depending.
I use 0.seconds for such oneshot receive attempts. Snippet:
while (!halt) {
if (++readCounter > messageCheckFrequency) {
receiveTimeout(0.seconds,
&_verbose.fun,
&_quiet.fun,
&_unknown.fun
);
readCounter = 0;
}
slice = conn.stream.readLine(buf);
// ...
}
More information about the Digitalmars-d-learn
mailing list