[[email protected]: Perl Event]

2003-11-15 Thread Joshua N Pritikin
- Forwarded message from Tom Howe <[EMAIL PROTECTED]> -

From: Tom Howe <[EMAIL PROTECTED]>
X-X-Sender: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: Perl Event

Hi, I have a query regarding Event. I am trying to build a network server 
that can take various requests from different clients, divide then into 
slices and process the slices on a first come/first served basis but im 
having difficulty with it.
I am using an IO event watcher to check for new data on the socket and 
using a VAR watcher to monitor a variable that is modified when a new 
slice is created. Unfortunately, when it is processing the slices it seems 
to completely ignore the IO watcher. It is as if the IO watcher doesnt get 
a look in while the VAR watcher is at work. I have tried various 
priorities but without success.

Is there somewhere suitable I can post this if you are unable to help?

Kind regards, Tom Howe


Re: [[email protected]: Perl Event]

2003-11-15 Thread Jochen Stenzel

Hello, Tom,

> I am trying to build a network server that can take various requests
> from different clients, divide then into slices and process the
> slices on a first come/first served basis but im having difficulty
> with it. I am using an IO event watcher to check for new data on the
> socket and using a VAR watcher to monitor a variable that is
> modified when a new slice is created. Unfortunately, when it is
> processing the slices it seems to completely ignore the IO watcher.
> It is as if the IO watcher doesnt get a look in while the VAR
> watcher is at work. I have tried various  priorities but without
> success.

honestly spoken, I neither know this problem nor its solution. This
needs to be investigated (and fixed if necessary). But possibly
there's a quick solution. Possibly you can achieve what you want
without this var watcher?

As I understand, the idea is that the connection request is handled by
an io watcher, which sets a variable, which causes the var watcher to
do whatever should be done for this slice.

In this scenario, I suggest to use an idle watcher to check for open
orders (e.g. to check your flags) and to handle them. It would be
invoked more often than a var watcher mentioned above, but that's no
problem and is proved to work.

  Jochen



Re: [[email protected]: Perl Event]

2003-11-15 Thread Robert Urban

You wrote:
> - Forwarded message from Tom Howe <[EMAIL PROTECTED]> -
> 
> From: Tom Howe <[EMAIL PROTECTED]>
> X-X-Sender: [EMAIL PROTECTED]
> To: [EMAIL PROTECTED]
> Subject: Perl Event
> 
> Hi, I have a query regarding Event. I am trying to build a network server 
> that can take various requests from different clients, divide then into 
> slices and process the slices on a first come/first served basis but im 
> having difficulty with it.
> I am using an IO event watcher to check for new data on the socket and 
> using a VAR watcher to monitor a variable that is modified when a new 
> slice is created. Unfortunately, when it is processing the slices it seems 
> to completely ignore the IO watcher. It is as if the IO watcher doesnt get 
> a look in while the VAR watcher is at work. I have tried various 

writing "while the VAR watcher is at work" is ambiguous.  Do you mean
while the VAR watcher *callback* is running?  Because that is what you
mean, the behaviour is normal: the event-loop must be entered in order
for an event to be serviced.

-RLU

> priorities but without success.
> 
> Is there somewhere suitable I can post this if you are unable to help?
> 
> Kind regards, Tom Howe




Re: [[email protected]: Perl Event]

2003-11-15 Thread Uri Guttman
> "JNP" == Joshua N Pritikin <[EMAIL PROTECTED]> writes:

  JNP> Hi, I have a query regarding Event. I am trying to build a
  JNP> network server that can take various requests from different
  JNP> clients, divide then into slices and process the slices on a
  JNP> first come/first served basis but im having difficulty with it.
  JNP> I am using an IO event watcher to check for new data on the
  JNP> socket and using a VAR watcher to monitor a variable that is
  JNP> modified when a new slice is created. Unfortunately, when it is
  JNP> processing the slices it seems to completely ignore the IO
  JNP> watcher. It is as if the IO watcher doesnt get a look in while
  JNP> the VAR watcher is at work. I have tried various priorities but
  JNP> without success.

you are basically trying to use a variable as a semaphore or work queue
flag. instead use a socket (socketpair) which you can add to the watched
events. when you have work to do, add it to a queue, and send something
small (a byte will do) down one end of the socket. the other end will
become readble and trigger an event (the one created above). this
event's callback take some work off the queue and does it. no muss, no
fuss.

a socket from a process to itself makes for a very clean semaphore that
can also be watched in any standard event loop.

uri

-- 
Uri Guttman  --  [EMAIL PROTECTED]   http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs    http://jobs.perl.org