source: t/threads.t @ 24f8cd

Revision 24f8cd, 711 bytes checked in by Tomash Brechko <tomash.brechko@…>, 2 years ago (diff)

use -> require, because we check for module presence at runtime.

  • Property mode set to 100644
Line 
1use warnings;
2use strict;
3
4use Test::More;
5
6use FindBin;
7
8use lib "$FindBin::Bin";
9use Memd;
10
11
12if ($^V lt v5.7.2) {
13   plan skip_all => 'Perl >= 5.7.2 is required';
14}
15
16use Config;
17unless ($Config{useithreads}) {
18   plan skip_all => 'ithreads are not configured';
19}
20
21use constant COUNT => 5;
22
23if ($Memd::memd) {
24    plan tests => COUNT * 2;
25} else {
26    plan skip_all => 'Not connected';
27}
28
29
30require threads;
31
32sub job {
33    my ($num) = @_;
34
35    $Memd::memd->set($num, $num);
36}
37
38my @threads;
39for my $num (1..COUNT) {
40    push @threads, threads->new(\&job, $num);
41}
42
43for my $num (1..COUNT) {
44    $threads[$num - 1]->join;
45
46    my $n = $Memd::memd->get($num);
47    is($n, $num);
48    ok($Memd::memd->delete($num));
49}
Note: See TracBrowser for help on using the repository browser.