NAME
Squatting::Q - define a separate session queue for a controller
SYNOPSIS
package App::Controllers;
use base 'Squatting::Q'
our @C = (
C(
Counter => '/count',
get => sub : Q(count) {
# ^^^^^^^^ see this?
},
)
);
DESCRIPTION
This module implements a subroutine attribute called Q
which takes an unquoted string as a parameter. "Q" is a mnemonic for "queue" and by defining a queue via the subroutine attribute, you can allow your controller to execute in a separate coroutine.
Why would I want to run in a separate coroutine?
My favorite answer is that running in a separate coroutine opens the door to some COMET-friendly techniques. Each coroutine has its own lexical scope, but it is also aware of the global scope of the program as well. This makes it possible (and even easy) to coordinate between multiple sessions in a multiuser web app.
(to be continued)