Michael S. Fischer
2007-Feb-27 12:27 UTC
[Eventmachine-talk] Waiting on a set of Deferrables
Hi everyone, I am building an server application that instantiates a number of Deferrable objects (each of which is a TCP client) and cannot issue a response to the client until all of said objects have performed their callbacks. In your experience, what''s the best way of doing this? Best regards, --Michael
Francis Cianfrocca
2007-Feb-27 14:32 UTC
[Eventmachine-talk] Waiting on a set of Deferrables
On 2/27/07, Michael S. Fischer <michael at dynamine.net> wrote:> > Hi everyone, > > I am building an server application that instantiates a number of > Deferrable objects (each of which is a TCP client) and cannot issue a > response to the client until all of said objects have performed their > callbacks. In your experience, what''s the best way of doing this?ARRRGGGGHHH! You WOULD ask exactly that question, wouldn''t you? :-) I''ve been wrestling with it myself. Until now I''ve been using a really crummy array, where I set a value in an array in a Deferrable callback and check the total number of responses in the array. If it''s the right number, you proceed. Gotta come up with something better. Like add the Deferrable to some other Deferrable that fires when all of its children have called back? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/eventmachine-talk/attachments/20070227/5b11f2bf/attachment.html
Michael S. Fischer
2007-Feb-27 15:04 UTC
[Eventmachine-talk] Waiting on a set of Deferrables
On 2/27/07, Francis Cianfrocca <garbagecat10 at gmail.com> wrote:> On 2/27/07, Michael S. Fischer <michael at dynamine.net> wrote:> > I am building an server application that instantiates a number of > > Deferrable objects (each of which is a TCP client) and cannot issue a > > response to the client until all of said objects have performed their > > callbacks. In your experience, what''s the best way of doing this?> ARRRGGGGHHH! You WOULD ask exactly that question, wouldn''t you? :-) > I''ve been wrestling with it myself. Until now I''ve been using a really > crummy array, where I set a value in an array in a Deferrable callback and > check the total number of responses in the array. If it''s the right number, > you proceed.Great minds think alike, I guess - that''s precisely the same solution I came up with!> Gotta come up with something better. Like add the Deferrable to some other > Deferrable that fires when all of its children have called back?I smell a recursive Deferrable. *head explodes* --Michael