| 1 | package EntityModel::StorageClass::KVStore::Mixin::Deferred; | ||||||||||
| 2 | { | ||||||||||
| 3 | 3 | $EntityModel::StorageClass::KVStore::Mixin::Deferred::VERSION = '0.102'; | |||||||||
| 4 | } | ||||||||||
| 5 | 3 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 3 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | =head2 has_pending | ||||||||||
| 9 | |||||||||||
| 10 | Returns true if there are pending tasks in the queue. | ||||||||||
| 11 | |||||||||||
| 12 | =cut | ||||||||||
| 13 | |||||||||||
| 14 | 0 | ▶ | sub has_pending { @{ shift->{queue} } } | ||||||||
|
Subroutine
has_pending: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 15 | |||||||||||
| 16 | =head2 run_pending | ||||||||||
| 17 | |||||||||||
| 18 | Processes any tasks pending in the queue. | ||||||||||
| 19 | |||||||||||
| 20 | =cut | ||||||||||
| 21 | |||||||||||
| 22 | 0 | ▶ | sub run_pending { | ||||||||
|
Subroutine
run_pending: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||
| 23 | 0 | my $self = shift; | |||||||||
| 24 | 0 | ▶ | return $self unless $self->is_connected; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 25 | 0 | ▶ | while(my $task = shift @{$self->{queue}}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 26 | 0 | my $method = shift @$task; | |||||||||
| 27 | 0 | $self->$method(@$task); | |||||||||
| 28 | } | ||||||||||
| 29 | 0 | $self; | |||||||||
| 30 | } | ||||||||||
| 31 | |||||||||||
| 32 | =head2 is_connected | ||||||||||
| 33 | |||||||||||
| 34 | Returns true if we have established a connection. | ||||||||||
| 35 | |||||||||||
| 36 | =cut | ||||||||||
| 37 | |||||||||||
| 38 | 0 | ▶ | sub is_connected { shift->{connected} } | ||||||||
|
Subroutine
is_connected: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 39 | |||||||||||
| 40 | =head2 queue_task | ||||||||||
| 41 | |||||||||||
| 42 | Queues a task for processing when we get around to connecting | ||||||||||
| 43 | later. | ||||||||||
| 44 | |||||||||||
| 45 | Takes the following parameters: | ||||||||||
| 46 | |||||||||||
| 47 | =over 4 | ||||||||||
| 48 | |||||||||||
| 49 | =item * $method - should be 'store' or 'retrieve' | ||||||||||
| 50 | |||||||||||
| 51 | =item * @args - any parameters, will be passed verbatim when we get around to | ||||||||||
| 52 | calling the method. | ||||||||||
| 53 | |||||||||||
| 54 | =back | ||||||||||
| 55 | |||||||||||
| 56 | Returns $self. | ||||||||||
| 57 | |||||||||||
| 58 | =cut | ||||||||||
| 59 | |||||||||||
| 60 | 0 | ▶ | sub queue_task { | ||||||||
|
Subroutine
queue_task: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 61 | 0 | my $self = shift; | |||||||||
| 62 | 0 | push @{ $self->{queue} }, [ @_ ]; | |||||||||
| 63 | 0 | $self | |||||||||
| 64 | } | ||||||||||
| 65 | |||||||||||
| 66 | =head2 connection_complete | ||||||||||
| 67 | |||||||||||
| 68 | Takes the following parameters: | ||||||||||
| 69 | |||||||||||
| 70 | =over 4 | ||||||||||
| 71 | |||||||||||
| 72 | =item * | ||||||||||
| 73 | |||||||||||
| 74 | =back | ||||||||||
| 75 | |||||||||||
| 76 | Returns $self. | ||||||||||
| 77 | |||||||||||
| 78 | =cut | ||||||||||
| 79 | |||||||||||
| 80 | 0 | ▶ | sub connection_complete { | ||||||||
|
Subroutine
connection_complete: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 81 | 0 | my $self = shift; | |||||||||
| 82 | 0 | $self->{connected} = 1; | |||||||||
| 83 | 0 | ▶ | $self->run_pending if $self->has_pending; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 84 | 0 | $self; | |||||||||
| 85 | } | ||||||||||
| 86 | |||||||||||
| 87 | 3 | 1; | |||||||||