| 1 | package POE::Wheel; | ||||||||||
| 2 | |||||||||||
| 3 | 110 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | 110 | ▶ | use vars qw($VERSION); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 110 | $VERSION = '1.370'; # NOTE - Should be #.### (three decimal places) | |||||||||
| 7 | |||||||||||
| 8 | 110 | ▶ | use Carp qw(croak); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | # Used to generate unique IDs for wheels. This is static data, shared | ||||||||||
| 11 | # by all. | ||||||||||
| 12 | 110 | my $current_id = 0; | |||||||||
| 13 | 110 | my %active_wheel_ids; | |||||||||
| 14 | |||||||||||
| 15 | 1 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 16 | 1 | my $type = shift; | |||||||||
| 17 | 1 | croak "$type is not meant to be used directly"; | |||||||||
| 18 | } | ||||||||||
| 19 | |||||||||||
| 20 | 609 | ▶ | sub allocate_wheel_id { | ||||||||
|
Subroutine
allocate_wheel_id: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 21 | 609 | while (1) { | |||||||||
| 22 | 612 | ▶ | last unless exists $active_wheel_ids{ ++$current_id }; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 23 | } | ||||||||||
| 24 | 609 | return $active_wheel_ids{$current_id} = $current_id; | |||||||||
| 25 | } | ||||||||||
| 26 | |||||||||||
| 27 | 527 | ▶ | sub free_wheel_id { | ||||||||
|
Subroutine
free_wheel_id: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 28 | 527 | my $id = shift; | |||||||||
| 29 | 527 | delete $active_wheel_ids{$id}; | |||||||||
| 30 | } | ||||||||||
| 31 | |||||||||||
| 32 | 3 | ▶ | sub _test_set_wheel_id { | ||||||||
|
Subroutine
_test_set_wheel_id: called CC=1 SCAR=0.0
| |||||||||||
| 33 | 3 | $current_id = shift; | |||||||||
| 34 | } | ||||||||||
| 35 | |||||||||||
| 36 | 110 | 1; | |||||||||
| 37 | |||||||||||
| 38 | __END__ | ||||||||||