Yeah I have a lotta legacy code that is really linear--like do this
then this then that. To convert it to EM I have to convert it
piece-wise, so, if I convert one piece, I want the original sequence
to block and wait for it (kind of a way to patch EM into the code).
For example if I want to run
if portOpen? ''localhost'', 2007
# then add it to the list
else
# don''t
end
If I want to use this code with EM (i.e. write the portOpen? function)
then I''ll need it to block until the answer comes back.
It works pretty well--though a kludge.
Take care :)
-Roger
On 11/19/07, Francis Cianfrocca <garbagecat10 at gmail.com>
wrote:> On Nov 19, 2007 3:45 PM, Roger Pack <rogerpack2005 at gmail.com>
wrote:
> > I was wondering if anybody has found an easier way to
''wait'' on an EM
> > call, than this
> >
> > a = Mutex.new
> > a.lock
> > EM.connect host, port {
> > # does stuff, finishes something, eventually calls a.unlock
> > }
> > a.synchronize # blocks
> >
> >
> > (I''m just wanting to block one thread waiting for an EM
process
> > waiting to return, to make integration easier in existing code).
> > Thoughts?
> > Thanks.
>
>
> This is novel. So you''re saying you want to suppress the standard
> behavior that EM allows other Ruby threads to run while it''s
running?
> Considering how hard it was to make that work, you can understand my
> surprise, LOL!