I’m using an Event var watcher to implement an internal queue. When the producer thread adds something to the queue (just an array) it will change the value of a watched variable to signal that an element was added.
How can you do the same with AnyEvent? It doesn’t seem to support variable watching. Do I have to use pipes and use an IO watcher (i.e. the producer writes a byte on one end of the pipe when it has added an element.)
I’d also be interested to know how to do this with Coro.
I figured out the paradigm to use:
Basically
$queue_watcheris defined and active if and only if@queueis not empty.