Zero timeout receive
John Colvin
john.loughran.colvin at gmail.com
Sat Apr 13 01:54:02 PDT 2013
On Saturday, 13 April 2013 at 01:26:16 UTC, James Wirth wrote:
> The discussion:
>
>
> http://forum.dlang.org/thread/mailman.426.1286264462.858.digitalmars-d@puremagic.com?page=9
>
> implies that:
> receiveTimeout(dur!"msecs"(0), some-callback-function)
>
> is acceptable - meaning that no blocking occurs. A simple
> experiment verifies this - but I hesitate to use "undocumented"
> features. Some APIs would interpret the 0 as infinity.
>
> I also fear that placing such a nonblocking recieve into the
> main event loop of a GUI program would impact performance - it
> would also be non-generic. Is there a fast function which
> returns true just when the "mail box" is non-empty?
>
> Thanks
Make a small test and time it. I personally wouldn't expect to
see much slowdown from the extra code invoked by receiveTimeout
compared to the rest of a busy loop.
However, either special casing receiveTimeout for 0 duration or
introducing a new receiveNoBlock or similar would be good.
More information about the Digitalmars-d
mailing list