| 1 | ## no critic (RequireUseStrict) | ||||||||||
| 2 | package Tapper::MCP::Scheduler::Algorithm::DummyAlgorithm; | ||||||||||
| 3 | 9 | our $AUTHORITY = 'cpan:TAPPER'; | |||||||||
| 4 | # ABSTRACT: Dummy algorithm for testing | ||||||||||
| 5 | 9 | $Tapper::MCP::Scheduler::Algorithm::DummyAlgorithm::VERSION = '5.0.9'; | |||||||||
| 6 | 9 | ▶ | use 5.010; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 9 | ▶ | use Moose::Role; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 9 | has current_queue_name => (is => "rw"); | |||||||||
| 10 | |||||||||||
| 11 | 105 | ▶ | sub lookup_next_queue { | ||||||||
|
Subroutine
lookup_next_queue: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||
| 12 | 105 | my ($self, $queues) = @_; | |||||||||
| 13 | |||||||||||
| 14 | 105 | my @ordered_queues = map { $queues->{$_} } sort keys %{$queues}; | |||||||||
| 15 | 105 | ▶ | return shift @ordered_queues if not $self->current_queue_name; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 16 | |||||||||||
| 17 | 95 | for my $i (0 .. $#ordered_queues) { | |||||||||
| 18 | 166 | ▶ | if ($self->current_queue_name eq $ordered_queues[$i]->name) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 19 | 93 | return $ordered_queues[($i+1) % int @ordered_queues]; | |||||||||
| 20 | } | ||||||||||
| 21 | } | ||||||||||
| 22 | 2 | return shift @ordered_queues; | |||||||||
| 23 | } | ||||||||||
| 24 | |||||||||||
| 25 | 6 | ▶ | sub get_next_queue { | ||||||||
|
Subroutine
get_next_queue: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 26 | 6 | my ($self, $queues) = @_; | |||||||||
| 27 | |||||||||||
| 28 | 6 | my $return_queue = $self->lookup_next_queue($queues); | |||||||||
| 29 | |||||||||||
| 30 | 6 | $self->update_queue($return_queue); | |||||||||
| 31 | 6 | return $return_queue; | |||||||||
| 32 | } | ||||||||||
| 33 | |||||||||||
| 34 | 32 | ▶ | sub update_queue { | ||||||||
|
Subroutine
update_queue: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 35 | 32 | my ($self, $Q) = @_; | |||||||||
| 36 | |||||||||||
| 37 | 32 | $self->current_queue_name( $Q->name ); | |||||||||
| 38 | 32 | return 0; | |||||||||
| 39 | } | ||||||||||
| 40 | |||||||||||
| 41 | 9 | 1; # End of Tapper::MCP::Scheduler::Algorithm::DummyAlgorithm | |||||||||
| 42 | |||||||||||
| 43 | __END__ | ||||||||||