>>>>> "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
