in reply to Re^2: PSGI, Plack, Twiggy, AnyEvent and SockJS... I need help
in thread PSGI, Plack, Twiggy, AnyEvent and SockJS... I need help
I guess, the module you create is already called from some event-driven system. In other words, your module is a "callback". The "callback" can't run it's own event distribution. You can register one more "callback" with the main system and then simply return control to the caller. The main system is then responsible for activating your new callback at appropriate time.
The AnyEvent module is event-distribution system. When you call $w->recv you activate this system, which blocks the main one, which in turn might trigger some time-out for killing your callback. Figure out how to add timers to the main framework. I don't know Plack and don't have any desire to study it, so I can't help you with this, sorry.
At the core, event-driven programming is very simple. The main part is manager looping over all possible events. When event is encountered, the manager checks if there are any "callbacks" waiting for this event. Those callbacks are activated and the looping continues. The callbacks must finish their work quickly and if necessary, they can register more callbacks for different events.
Everything else, is specific ways, how different managers keep track of callbacks and events.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: PSGI, Plack, Twiggy, AnyEvent and SockJS... I need help
by Corion (Patriarch) on Apr 09, 2014 at 07:53 UTC | |
|
Re^4: PSGI, Plack, Twiggy, AnyEvent and SockJS... I need help
by xtpu2 (Acolyte) on Apr 09, 2014 at 14:39 UTC | |
by Corion (Patriarch) on Apr 09, 2014 at 15:41 UTC | |
by xtpu2 (Acolyte) on Apr 09, 2014 at 17:05 UTC | |
by Corion (Patriarch) on Apr 09, 2014 at 17:27 UTC | |
by xtpu2 (Acolyte) on Apr 09, 2014 at 18:56 UTC | |
|