| 1 | package Object::InsideOut::Secure; { | ||
| 2 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | |||
| 5 | 1 | our $VERSION = '4.03'; | |
| 6 | 1 | $VERSION = eval $VERSION; | |
| 7 | |||
| 8 | 1 | ▶ | use Object::InsideOut 4.03 ':hash_only'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | |||
| 10 | # Holds used IDs | ||
| 11 | 1 | my %used :Field = ( 0 => undef ); | |
| 12 | |||
| 13 | # Our PRNG | ||
| 14 | BEGIN { | ||
| 15 | 1 | ▶ | $Math::Random::MT::Auto::shared = $threads::shared::threads_shared; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 16 | } | ||
| 17 | 1 | ▶ | use Math::Random::MT::Auto 5.04 ':!auto'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 18 | 1 | my $prng = Math::Random::MT::Auto->new(); | |
| 19 | |||
| 20 | # Assigns random IDs | ||
| 21 | sub _id :ID | ||
| 22 | { | ||
| 23 | my $id; | ||
| 24 | while (exists($used{$id = $prng->irand()})) {} | ||
| 25 | $used{$id} = undef; | ||
| 26 | return $id; | ||
| 27 | 1 | ▶ | } |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 28 | } | ||
| 29 | |||
| 30 | 1 | 1; | |
| 31 | |||
| 32 | # EOF | ||