SEARCH
NEW RPMS
DIRECTORIES
ABOUT
FAQ
VARIOUS
BLOG
DONATE


YUM REPOSITORY

 
 

MAN page from openSUSE Leap 15 perl-Class-Std-Fast-0.0.8-lp151.4.1.x86_64.rpm

Class::Std::Fast

Section: User Contributed Perl Documentation (3)
Updated: 2016-07-06
Index 

NAME

Class::Std::Fast - faster but less secure than Class::Std 

VERSION

This document describes Class::Std::Fast 0.0.8 

SYNOPSIS

    package MyClass;    use Class::Std::Fast;    1;    package main;    MyClass->new();
 

DESCRIPTION

Class::Std::Fast allows you to use the beautiful API of Class::Std in afaster way than Class::Std does.

You can get the object's ident via scalarifiyng your object.

Getting the objects ident is still possible via the ident method, but it'sfaster to scalarify your object. 

SUBROUTINES/METHODS

 

new

The constructor acts like Class::Std's constructor. For extended constructorssee Constructors below.

    package FastObject;    use Class::Std::Fast;    1;    my $fast_obj = FastObject->new();
 

ident

If you use Class::Std::Fast you shouldn't use this method. It's only existantfor downward compatibility.

    # insted of    my $ident = ident $self;    # use    my $ident = ${$self};
 

initialize

    Class::Std::Fast::initialize();

Imported from Class::Std. Please look at the documentation fromClass::Std for more details. 

Methods for accessing Class::Std::Fast's internals

Class::Std::Fast exposes some of it's internals to allow the constructionof Class::Std::Fast based objects from outside the auto-generatedconstructors.

You should never use these methods for doing anything else. In fact youshould not use these methods at all, unless you know what you're doing. 

ID

Returns an ID for the next object to construct.

If you ever need to override the constructor created by Class::Std::Fast,be sure to use Class::Std::Fast::ID as the source for the ID to assign toyour blessed scalar.

More precisely, you should construct your object like this:

    my $self = bless \do { my $foo = Class::Std::Fast::ID } , $class;

Every other method of constructing Class::Std::Fast - based objects will leadto data corruption (duplicate object IDs). 

ID_GENERATOR_REF

Returns a reference to the ID counter scalar.

The current value is the next object ID !

You should never use this method unless you're trying to createClass::Std::Fast objects from outside Class::Std::Fast (and possibly outsideperl).

In case you do (like when creating perl objects in XS code), be sure topost-increment the ID counter after creating an object, which you may dofrom C with

    sv_inc( SvRV(id_counter_ref) )
 

OBJECT_CACHE_REF

Returns a reference to the object cache.

You should never use this method unless your're trying to (re-)createClass::Std::Fast objects from outside Class::Std::Fast (and possibly outsideperl).

See <L/EXTENSIONS TO Class::Std> for a description of the object cachefacility. 

EXTENSIONS TO Class::Std

 

Methods

real_can

Class::Std::Fast saves away UNIVERSAL::can as Class::Std::Fast::real_can beforeoverwriting it. You should not use real_can, because it does not check forsubroutines implemented via AUTOMETHOD.

It is there if you need the old can() for speed reasons, and know what you'redoing. 

Constructors

Class::Std::Fast allows the user to chose between several constructoroptions.
*
Standard constructor

No special synopsis. Acts like Class::Std's constructor

*
Basic constructor

 use Class::Std::Fast qw(2); use Class::Std::Fast constructor => 'basic';

Does not call BUILD and START (and does not walk down the inheritancehierarchy calling BUILD and START).

Does not perform any attribute initializations.

Really fast, but very basic.

*
No constructor

 use Class::Std::Fast qw(3); use Class::Std::Fast constructor => 'none';

No constructor is exported into the calling class.

The recommended usage is:

 use Class::Std::Fast constructor => none; sub new {     my $self = bless \do { my $foo = Class::Std::Fast::ID } , $_[0];     # do what you need to do after that }

If you use the Object Cache (see below) the recommended usage is:

 use Class::Std::Fast constructor => 'none', cache => 1; sub new {     my $self = pop @{ Class::Std::Fast::OBJECT_CACHE_REF()->{ $_[0] } }        || bless \do { my $foo = Class::Std::Fast::ID() } , $_[0]; }
 

Destructors

Class::Std sorts the @ISA hierarchy before traversing it to avoid cleaningup the wrong class first. However, this is unneccessary if the class inquestion has a linear inheritance tree.

Class authors may disable sorting by calling

 use Class::Std::Fast unsorted => 1;

Use only if you know your class' complete inheritance tree... 

Object Cache

Synopsis

 use Class::Std::Fast cache => 1;

Description

While inside out objects are basically an implementation of the FlyweightPattern (object data is stored outside the object), there's still one aspectmissing: object reuse. While Class::Std::Fast does not provide flyweightsin the classical sense (one object re-used again and again), it providessomething close to it: An object cache for re-using destroyed objects.

The object cache is implemented as a simple hash with the class names of thecached objects as keys, and a list ref of cached objects as values.

The object cache is filled by the DESTROY method exported into allClass::Std::Fast based objects: Instead of actually destroying the blessedscalar reference (Class::Std::Fast based objects are nothing more), theobject to be destroyed is pushed into it's class' object cache.

new() in turn does not need to create a new blessed scalar, but can just popone off the object cache (which is a magnitude faster).

Using the object cache is recommended for persistent applications (likerunning under mod_perl), or applications creating and destroyinglots of Class::Std::Fast based objects again and again.

The exported constructor automatically uses the Object Cache when caching isenabled by setting the cache import flag to a true value.

For an example of a user-defined constructor see ``Constructors'' above.

Memory overhead

The object cache trades speed for memory. This is a very perlish way foradressing performance issues, but may cause your application to blow upif you're short of memory.

On a 32bit Linux, Devel::Size reports 44 bytes for a Class::Std::Fast basedobject - so a cache containing 1 000 000 (one million) of objects needsaround 50MB of memory (Devel Size only reports the memory use it can see -the actual usage is system dependent and something between 4 and 32 bytesmore).

If you are anxious about falling short of memory, only enable caching forthose classes whose objects you know to be frequently created and destroyed,and leave it turned off for the less frequently used classes - this gives youboth speed benefits, and avoids holding a cache of object that will never beneeded again. 

DIAGNOSTICS

see Class::Std.

Additional diagnostics are:

*
Class::Std::Fast loaded too late - put >use Class::Std::Fast< somewhere at the top of your application (warning)

Class::Std has been ``use''d before Class::Std::Fast. While both classeshappily coexist in one application, Class::Std::Fast must be loaded firstfor maximum speedup.

This is due to both classes overwriting UNIVERSAL::can. Class::Std::Fast usesthe original (fast) can where appropritate, but cannot access it ifClass::Std has overwritten it before with it's (slow) replacement.

 

CONFIGURATION AND ENVIRONMENT

 

DEPENDENCIES

*
version
*
Class::Std
*
Carp
 

INCOMPATIBILITIES

see Class::Std 

BUGS AND LIMITATIONS

*
You can't use the :SCALARIFY attribute for your Objects.

We use an increment for building identifiers and not Scalar::Util::refaddrlike Class::Std.

*
Inheriting from non-Class::Std::Fast modules does not work

You cannot inherit from non-Class::Std::Fast classes, not even if youoverwrite the default constructor. To be more precise, you cannot inheritfrom classes which use something different from numeric blessed scalarreferences as their objects. Even so inheriting from similarly contructedclasses like Object::InsideOut could work, you would have to make sure thatobject IDs cannot be duplicated. It is therefore strongly discouraged tobuild classes with Class::Std::Fast derived from non-Class::Std::Fast classes.

If you really need to inherit from non-Class::Std::Fast modules, make sureyou use Class::Std::Fast::ID as described above for creating objects.

*
No runtime initialization with constructor => 'basic' / 'none'

When eval'ing Class::Std::Fast based classes using the basic constructor,make sure the last line is

 Class::Std::Fast::initialize();

In contrast to Class::Std, Class::Std::Fast performs no run-timeinitialization when the basic constructor is enabled, so your code has todo it itself.

The same holds true for constructor => 'none', of course.

CUMULATIVE, PRIVATE, RESTRICTED and anticumulative methods won't work if youleave out this line.

 

RCS INFORMATIONS

Last changed by
$Author: ac0v $
Id
$Id: Fast.pm 469 2008-05-26 11:26:35Z ac0v $
Revision
$Revision: 469 $
Date
$Date: 2008-05-26 13:26:35 +0200 (Mon, 26 May 2008) $
HeadURL
$HeadURL: file:///var/svn/repos/Hyper/Class-Std-Fast/branches/0.0.8/lib/Class/Std/Fast.pm $
 

AUTHORS

Andreas 'ac0v' Specht "<ACIDAATTcpan.org>"

Martin Kutter "<martin.kutterAATTfen-net.de>" 

LICENSE AND COPYRIGHT

Copyright (c) 2007, Andreas Specht "<ACIDAATTcpan.org>".All rights reserved.

This module is free software; you can redistribute it and/ormodify it under the same terms as Perl itself.


 

Index

NAME
VERSION
SYNOPSIS
DESCRIPTION
SUBROUTINES/METHODS
new
ident
initialize
Methods for accessing Class::Std::Fast's internals
ID
ID_GENERATOR_REF
OBJECT_CACHE_REF
EXTENSIONS TO Class::Std
Methods
Constructors
Destructors
Object Cache
DIAGNOSTICS
CONFIGURATION AND ENVIRONMENT
DEPENDENCIES
INCOMPATIBILITIES
BUGS AND LIMITATIONS
RCS INFORMATIONS
AUTHORS
LICENSE AND COPYRIGHT

This document was created byman2html,using the manual pages.