[Spread-users] Multiple connections: how long between calls to SP_poll() ?

John Robinson jr at vertica.com
Thu Aug 30 10:56:29 EDT 2007


Better wait a short time.

Or you can actually use the poll() (or select()) system call on the 
collection of mboxes to wait until any of them has more for you to 
process.  They behave like normal non-blocking fd's in this respect.

The event system packaged with spread can also help with this.

/jr
---
matthew.garman at gmail.com wrote:
> I've got an application that creates several spread connections to
> different spread daemons.
> 
> My code structure is basically like this:
> 
> /* assume five spread connections to five different
>  * spread daemons */
> mailbox mbox[5];
> while (1) {
>     for (i=0; i<5; i++) {
>         if (SP_poll(mbox[i])) {
>             /* receive data, do something interesting */
>         }
>     }
>     sleep(n); /* what's the max value of n? */
> }
> 
> My question is, what is the maximum value I can sleep between calls
> to SP_poll() without missing any messages?  (I.e., to minimize CPU
> usage?)
> 
> Obviously I can't use SP_receive() here, since it blocks (unless I
> wrote a multi-threaded program, which I'm trying to avoid).
> 
> In other words, how long will a spread daemon "hold" a message
> for its clients?
> 
> Thanks,
> Matt
> 
> 
> _______________________________________________
> Spread-users mailing list
> Spread-users at lists.spread.org
> http://lists.spread.org/mailman/listinfo/spread-users




More information about the Spread-users mailing list