NAME

Thread::Serialize - serialize data-structures between threads

SYNOPSIS

use Thread::Serialize;    # export freeze() and thaw()

use Thread::Serialize (); # must call fully qualified subs

my $frozen = freeze( any data structure );
any data structure = thaw( $frozen );

DESCRIPTION

                 *** A note of CAUTION ***

This module only functions on Perl versions 5.8.0 and later.
And then only when threads are enabled with -Dusethreads.  It
is of no use with any version of Perl before 5.8.0 or without
threads enabled.

                 *************************

The Thread::Serialize module is a library for centralizing the routines used to serialize data-structures between threads. Because of this central location, other modules such as Thread::Conveyor, Thread::Pool or Thread::Tie can benefit from the same optimilizations that may take place here in the future.

SUBROUTINES

There are only two subroutines.

freeze

my $frozen = freeze( $scalar );

my $frozen = freeze( @array );

The "freeze" subroutine takes all the parameters passed to it, freezes them and returns a frozen representation of what was given. The parameters can be scalar values or references to arrays or hashes. Use the thaw subroutine to obtain the original data-structure back.

thaw

my $scalar = thaw( $frozen );

my @array = thaw( $frozen );

The "thaw" subroutine returns the data-structure that was frozen with a call to freeze. If called in a scalar context, only the first element of the data-structure that was passed, will be returned. Otherwise the entire data-structure will be returned.

It is up to the developer to make sure that single argument calls to freeze are always matched by scalar context calls to thaw.

AUTHOR

Elizabeth Mattijsen, <liz@dijkmat.nl>.

Please report bugs to <perlbugs@dijkmat.nl>.

COPYRIGHT

Copyright (c) 2002 Elizabeth Mattijsen <liz@dijkmat.nl>. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

SEE ALSO

Thread::Conveyor, Thread::Pool, Thread::Tie.