Thanks Rob, but then what is the time-slice for? I thought POE provides the
time-slicing
as in a typical operating system (collaborative or pre-emptive
multi-tasking?). Are you saying that if
an event handler is blocking (either CPU or IO), POE wont' pause it to
handle other events? like magic?

Z.

----- Original Message ----- 
From: "Rob Bloodgood" <[EMAIL PROTECTED]>
To: "sir shz" <[EMAIL PROTECTED]>; <[email protected]>
Sent: Tuesday, April 19, 2005 1:13 PM
Subject: Re: how POE handles long running functions/blocking


> sir shz wrote:
> > 1. functions that may take some time (e.g., a long loop)
>
> It blocks.
>
> > 2. functions that wait on IO (either just waiting, or say reading a huge
> > file)
>
> It blocks.
>
> > Does it treat them the same way, by allocating short time slices?
> >
> > I was reading a little bit about Python/Twisted, it has a concept of
> > Deferred,
> > roughly the above two types of methods will return right away, a
Deffered
> > object, then
> > one registers call backs when the real data comes in. One thing I don't
like
> > about
> > it (as little as I know about it) is that as a programmer, I have to
decide
> > this
> > when I code the function, and when I call it. I'm wondering how this is
> > deferrent
> > from the way POE does, and advantages/disadvantages.
>
> In order to achieve concurrency, you have to code in a non-blocking
> fashion.  This means one of: A) working with POE's non-blocking
> filehandles and sockets, B) forking a child process with Wheel::Run, or
> C) coding something non-blocking yourself, and using POE's events to
> perform a slice at a time.  Note that for C), this means your algorithm
> must explicitly "give up" its timeslice, and be called again (either on
> I/O on a handle, or by post()ing an event back to yourself).
>
> HTH!
>
> L8r,
> Rob

Reply via email to