forked from miyagawa/Hash-MultiValue
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request miyagawa#1 from chansen/master
Thread safety
- Loading branch information
Showing
2 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
use strict; | ||
use Config; | ||
use Test::More; | ||
use Hash::MultiValue; | ||
|
||
BEGIN { | ||
plan skip_all => "perl interpreter is not compiled with ithreads" | ||
unless $Config{useithreads}; | ||
|
||
require threads; | ||
} | ||
|
||
plan tests => 2; | ||
|
||
my $h = Hash::MultiValue->new(foo => 'bar'); | ||
my @exp = ('bar'); | ||
|
||
is_deeply([$h->get_all('foo')], \@exp, 'got expected results'); | ||
|
||
my @got = threads->create(sub { | ||
$h->get_all('foo'); | ||
})->join; | ||
|
||
is_deeply(\@got, \@exp, 'got expected results in cloned interpreter'); | ||
|