Uname: Linux web3.us.cloudlogin.co 5.10.226-xeon-hst #2 SMP Fri Sep 13 12:28:44 UTC 2024 x86_64
Software: Apache
PHP version: 8.1.31 [ PHP INFO ] PHP os: Linux
Server Ip: 162.210.96.117
Your Ip: 18.117.156.38
User: edustar (269686) | Group: tty (888)
Safe Mode: OFF
Disable Function:
NONE

name : Array.pm
package Test::SharedFork::Array;
use strict;
use warnings;
use base 'Tie::Array';
use Storable ();

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


sub _get {
    my $self = shift;
    my $lock = $self->{share}->get_lock();
    return $self->{share}->get($self->{key});
}
sub FETCH {
    my ($self, $index) = @_;
    $self->_get()->[$index];
}
sub FETCHSIZE {
    my $self = shift;
    my $ary = $self->_get();
    scalar @$ary;
}

sub STORESIZE {
    my ($self, $size) = @_;
    my $lock = $self->{share}->get_lock();
    my $ary  = $self->_get();
    $#$ary   = $size - 1;
}

sub STORE {
    my ($self, $index, $val) = @_;

    my $lock = $self->{share}->get_lock();

    my $share = $self->{share};
    my $cur = $share->get($self->{key});
    $cur->[$index] = $val;
    $share->set($self->{key} => $cur);
}

1;
© 2025 GrazzMean