| 1 | package Net::Async::Beanstalk::Stack; | ||||||||||
| 2 | |||||||||||
| 3 | 3 | our $VERSION = '0.001'; | |||||||||
| 4 | 3 | $VERSION = eval $VERSION; | |||||||||
| 5 | |||||||||||
| 6 | =head1 NAME | ||||||||||
| 7 | |||||||||||
| 8 | Net::Async::Beanstalk::Stack - A FIFO stack of queued commands | ||||||||||
| 9 | |||||||||||
| 10 | =head1 DOCUMENTED ELSEWHERE | ||||||||||
| 11 | |||||||||||
| 12 | This module's external API is undocumented. | ||||||||||
| 13 | |||||||||||
| 14 | =cut | ||||||||||
| 15 | |||||||||||
| 16 | 3 | ▶ | use Moo::Role; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 17 | 3 | ▶ | use strictures 2; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 18 | |||||||||||
| 19 | 3 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 20 | 3 | ▶ | use MooX::HandlesVia; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 21 | 3 | ▶ | use namespace::clean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 22 | |||||||||||
| 23 | # TODO: Document internal API | ||||||||||
| 24 | |||||||||||
| 25 | =head1 ATTRIBUTES | ||||||||||
| 26 | |||||||||||
| 27 | =over | ||||||||||
| 28 | |||||||||||
| 29 | =item _command_stack | ||||||||||
| 30 | |||||||||||
| 31 | =for comment Documented last because this attribue isn't particularly | ||||||||||
| 32 | interesting to users of this module. | ||||||||||
| 33 | |||||||||||
| 34 | An internal FIFO stack of commands which are waiting to be sent or | ||||||||||
| 35 | responded to. | ||||||||||
| 36 | |||||||||||
| 37 | Accessors: | ||||||||||
| 38 | |||||||||||
| 39 | =over | ||||||||||
| 40 | |||||||||||
| 41 | =item count_commands | ||||||||||
| 42 | |||||||||||
| 43 | How many commands are in the stack, including the one which the server | ||||||||||
| 44 | is currently processing. | ||||||||||
| 45 | |||||||||||
| 46 | =item current_command | ||||||||||
| 47 | |||||||||||
| 48 | Returns the command the server is currently processing, or has just | ||||||||||
| 49 | sent a response to, without removing it from the stack. | ||||||||||
| 50 | |||||||||||
| 51 | =item is_busy | ||||||||||
| 52 | |||||||||||
| 53 | A boolean indicating whether the client is busy, ie. has a command | ||||||||||
| 54 | currently being processed or has commands waiting to be sent. Actually | ||||||||||
| 55 | implemented by the same method as L</count_commands>. | ||||||||||
| 56 | |||||||||||
| 57 | =item _pending_commands | ||||||||||
| 58 | |||||||||||
| 59 | Returns the commands which have not yet completed, including the one | ||||||||||
| 60 | which the server is currently processing. | ||||||||||
| 61 | |||||||||||
| 62 | =item _push_command | ||||||||||
| 63 | |||||||||||
| 64 | Push a new command onto the stack. | ||||||||||
| 65 | |||||||||||
| 66 | =item _shift_command | ||||||||||
| 67 | |||||||||||
| 68 | Remove and return the first command from the stack, which the server | ||||||||||
| 69 | is either processing or has returned a response to. | ||||||||||
| 70 | |||||||||||
| 71 | =back | ||||||||||
| 72 | |||||||||||
| 73 | =cut | ||||||||||
| 74 | |||||||||||
| 75 | has _command_stack => ( | ||||||||||
| 76 | is => 'ro', | ||||||||||
| 77 | init_arg => undef, | ||||||||||
| 78 | 0 | ▶ | default => sub { [] }, | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 79 | 3 | handles_via => 'Array', | |||||||||
| 80 | handles => { | ||||||||||
| 81 | count_commands => 'count', | ||||||||||
| 82 | is_busy => 'count', | ||||||||||
| 83 | _pending_commands => 'all', | ||||||||||
| 84 | _push_command => 'push', | ||||||||||
| 85 | _shift_command => 'shift', | ||||||||||
| 86 | }, | ||||||||||
| 87 | ); | ||||||||||
| 88 | |||||||||||
| 89 | 0 | ▶ | sub current_command { $_[0]->_command_stack->[0] || croak "No active command" } | ||||||||
|
Subroutine
current_command: not called CC=2 SCAR=17.9
Pod
documented
Branch: 1 branch
| |||||||||||
| 90 | |||||||||||
| 91 | =back | ||||||||||
| 92 | |||||||||||
| 93 | =cut | ||||||||||
| 94 | |||||||||||
| 95 | 3 | 1; | |||||||||