The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

MCE::Shared::Scalar - Scalar helper class

VERSION

This document describes MCE::Shared::Scalar version 1.699_009

SYNOPSIS

   # non-shared
   use MCE::Shared::Scalar;

   my $var = MCE::Shared::Scalar->new( $val );

   # shared
   use MCE::Shared;

   my $var = MCE::Shared->scalar( $val );

   # oo interface
   $val = $var->set( $val );
   $val = $var->get();
   $len = $var->len();

   # sugar methods without having to call set/get explicitly
   $val = $var->append( $string );            #   $val .= $string
   $val = $var->decr();                       # --$val
   $val = $var->decrby( $number );            #   $val -= $number
   $val = $var->getdecr();                    #   $val--
   $val = $var->getincr();                    #   $val++
   $val = $var->incr();                       # ++$val
   $val = $var->incrby( $number );            #   $val += $number
   $old = $var->getset( $new );               #   $o = $v, $v = $n, $o

DESCRIPTION

Helper class for MCE::Shared.

API DOCUMENTATION

new ( value )
new

Construct a new scalar object. The value defaults to undef unless value is specified.

set ( value )

Set scalar to value.

get

Get the scalar value.

len

Get the length of the scalar value.

SUGAR METHODS

This module is equipped with sugar methods to not have to call set and get explicitly. The API resembles a subset of the Redis primitives http://redis.io/commands#strings without the key argument.

append ( value )

Append the value at the end of the scalar value.

decr

Decrement the value by one and return its new value.

decrby ( number )

Decrement the value by the given number and return its new value.

getdecr

Decrement the value by one and return its old value.

getincr

Increment the value by one and return its old value.

getset ( value )

Set to value and return its old value.

incr

Increment the value by one and return its new value.

incrby ( number )

Increment the value by the given number and return its new value.

CREDITS

The implementation is inspired by Tie::StdScalar.

INDEX

MCE, MCE::Core, MCE::Shared

AUTHOR

Mario E. Roy, <marioeroy AT gmail DOT com>