Note: This is a mailing list. Please hit "Reply All" so your mail goes to
the list as well otherwise my replies won't make sense to somebody browsing
the archives with the same problem later.
On Mon, May 16, 2005 at 07:02:19PM +0400, Laura wrote:
> Thank you very much! Now I know the mistake, i just need
> to use call instead of yield, but when i try for example
> to 'post' LaDBI, and increment($_[HEAP]->{VARIABLE}++) in
> next sub, it doesn`t work :(
No, you don't need to use call. You're still attempting to write a simple
linear system in an event-driven framework.
post will put an event on LaDBI's queue
LaDBI will then handle that in the background over the course of a while,
and post an event back to your session with the results.
It's a state machine - think how button clicks by the user fire events in
most GUI systems. This is kinda the same except you get to fire the events
from your code yourself.
What you want is to have another event handler that gets the reply from
LaDBI and does something useful with it - then you can yield from that
to increment your counter.
Same thing on disconnect - you can't decrement the connection counter until
you have *receieved* the disconnect acknowledgement event from LaDBI, which
means registering something to handle that event and waiting for LaDBI to
send it.
If you're not clear on the event-driven programming concepts, a quick google
for "event driven programming" provided a bunch of tutorials that might
help you there.
If it's any consolation, POE took me a while to wrap my brain around too :)
--
Matt S Trout Website: http://www.shadowcatsystems.co.uk
Technical Director E-mail: mst (at) shadowcatsystems.co.uk
Shadowcat Systems Ltd.