[Spread-users] Receive with timeout
John Schultz
jschultz at spreadconcepts.com
Thu Jun 1 09:48:44 EDT 2006
Mark Snelling wrote:
>Hi
>
>Is there any chance of adding variants of the receive and poll functions
>that accept a timeout parameter?
>
>The combination of the current non-blocking SP_poll() and blocking
>SP_receive() functions make it quite tricky to have a separate receive
>thread, which is quite a common approach for distributed applications.
>
>The problem is that the receive thread blocks while waiting for messages,
>this means there can be no other processing done if there is nothing pending
>(also making shutdown difficult). If you were to poll first and then receive
>if there were messages pending the receive thread would spin as it
>constantly polled. You may add some form of sleep here but that will just
>add extra latency in the time it takes to process the message.
>
>
Commonly, people will use select or poll system calls to watch for
activity on the mailbox, which is a file descriptor. For a receive
thread, you would simply wait for read activity on the mailbox and then
call SP_receive, which will then block until all the bytes are received.
Cheers!
---
John Schultz
Spread Concepts LLC
Phn: 301 498 3233
Cell: 443 838 2200
More information about the Spread-users
mailing list