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