| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package IPC::PrettyPipe::Queue; | 
| 2 |  |  |  |  |  |  |  | 
| 3 |  |  |  |  |  |  | # ABSTRACT: A simple queue | 
| 4 |  |  |  |  |  |  |  | 
| 5 | 14 |  |  | 14 |  | 97 | use Moo; | 
|  | 14 |  |  |  |  | 33 |  | 
|  | 14 |  |  |  |  | 111 |  | 
| 6 |  |  |  |  |  |  |  | 
| 7 |  |  |  |  |  |  | our $VERSION = '0.12'; | 
| 8 |  |  |  |  |  |  |  | 
| 9 | 14 |  |  | 14 |  | 5012 | use namespace::clean; | 
|  | 14 |  |  |  |  | 34 |  | 
|  | 14 |  |  |  |  | 115 |  | 
| 10 |  |  |  |  |  |  |  | 
| 11 |  |  |  |  |  |  |  | 
| 12 |  |  |  |  |  |  | has elements => ( | 
| 13 |  |  |  |  |  |  | is       => 'ro', | 
| 14 |  |  |  |  |  |  | init_arg => undef, | 
| 15 |  |  |  |  |  |  | default  => sub { [] }, | 
| 16 |  |  |  |  |  |  | ); | 
| 17 |  |  |  |  |  |  |  | 
| 18 | 45 |  |  | 45 | 1 | 27175 | sub empty { !!!@{ $_[0]->elements } } | 
|  | 45 |  |  |  |  | 188 |  | 
| 19 |  |  |  |  |  |  |  | 
| 20 | 0 |  |  | 0 | 1 | 0 | sub nelements { scalar @{ $_[0]->elements } } | 
|  | 0 |  |  |  |  | 0 |  | 
| 21 |  |  |  |  |  |  |  | 
| 22 |  |  |  |  |  |  | sub push { | 
| 23 |  |  |  |  |  |  |  | 
| 24 | 299 |  |  | 299 | 1 | 7121 | my ( $self, $elem ) = ( shift, shift ); | 
| 25 |  |  |  |  |  |  |  | 
| 26 | 299 | 50 |  |  |  | 1345 | die( "incompatible element\n" ) | 
| 27 |  |  |  |  |  |  | unless $elem->does( 'IPC::PrettyPipe::Queue::Element' ); | 
| 28 |  |  |  |  |  |  |  | 
| 29 | 299 |  |  |  |  | 7093 | my $elements = $self->elements; | 
| 30 |  |  |  |  |  |  |  | 
| 31 | 299 | 100 |  |  |  | 858 | if ( @$elements ) { | 
| 32 |  |  |  |  |  |  | ## no critic (ProhibitAccessOfPrivateData) | 
| 33 | 135 |  |  |  |  | 443 | $elements->[-1]->_set_last( 0 ); | 
| 34 | 135 |  |  |  |  | 288 | $elem->_set_last( 1 ); | 
| 35 | 135 |  |  |  |  | 438 | $elem->_set_first( 0 ); | 
| 36 |  |  |  |  |  |  | } | 
| 37 |  |  |  |  |  |  | else { | 
| 38 |  |  |  |  |  |  |  | 
| 39 | 164 |  |  |  |  | 457 | $elem->_set_last( 1 ); | 
| 40 | 164 |  |  |  |  | 432 | $elem->_set_first( 1 ); | 
| 41 |  |  |  |  |  |  |  | 
| 42 |  |  |  |  |  |  | } | 
| 43 |  |  |  |  |  |  |  | 
| 44 | 299 |  |  |  |  | 449 | push @{$elements}, $elem; | 
|  | 299 |  |  |  |  | 672 |  | 
| 45 |  |  |  |  |  |  |  | 
| 46 | 299 |  |  |  |  | 747 | return; | 
| 47 |  |  |  |  |  |  | } | 
| 48 |  |  |  |  |  |  |  | 
| 49 |  |  |  |  |  |  | 1; | 
| 50 |  |  |  |  |  |  |  | 
| 51 |  |  |  |  |  |  | # | 
| 52 |  |  |  |  |  |  | # This file is part of IPC-PrettyPipe | 
| 53 |  |  |  |  |  |  | # | 
| 54 |  |  |  |  |  |  | # This software is Copyright (c) 2018 by Smithsonian Astrophysical Observatory. | 
| 55 |  |  |  |  |  |  | # | 
| 56 |  |  |  |  |  |  | # This is free software, licensed under: | 
| 57 |  |  |  |  |  |  | # | 
| 58 |  |  |  |  |  |  | #   The GNU General Public License, Version 3, June 2007 | 
| 59 |  |  |  |  |  |  | # | 
| 60 |  |  |  |  |  |  |  | 
| 61 |  |  |  |  |  |  | __END__ |