File: Scalar.pm

package info (click to toggle)
libcatalyst-engine-psgi-perl 0.13%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 444 kB
  • sloc: perl: 5,307; sh: 48; makefile: 2
file content (27 lines) | stat: -rw-r--r-- 538 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#line 1
package Test::SharedFork::Scalar;
use strict;
use warnings;
use base 'Tie::Scalar';

# create new tied scalar
sub TIESCALAR {
    my ($class, $share, $key) = @_;
    die "missing key" unless $key;
    bless { share => $share, key => $key }, $class;
}

sub FETCH {
    my $self = shift;
    my $lock = $self->{share}->get_lock();
    $self->{share}->get($self->{key});
}

sub STORE {
    my ($self, $val) = @_;
    my $share = $self->{share};
    my $lock = $self->{share}->get_lock();
    $share->set($self->{key} => $val);
}

1;