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

NAME

threads::emulate - Create and use emulated threads (and share vars easyer)

VERSION

Version 0.0.4

SYNOPSIS

This module was made because I don't like to have to "declare" every "sub-level" of a shared var using threads::shared. This is NOT real threads. We use UNIX sockets to emulate shared variables.

    use threads::emulate;
    
    my $shared_var : Shared;
    
    $shared_var = [1..5];                      # Congratulations! Now you have a shared array_ref!
    $shared_var->[5] = {jan => 1, feb => 2};   # Now inside of the array_ref there's a hash_ref!
    $shared_var->[5]->{obj} = Any::Class->new; # End now there's a object!
    
    lock \$shared_var;                         # Yes... You have to use ref...
    
    async{
        lock \$shared_var;
        $shared_var->[0] .= "K";
    };
    
    $shared_var->[0] = "O";
    unlock \$shared_var;

    sleep 1;

    print $shared_var->[0], $/;                # prints "OK" (I hope... :) )

EXPORT

This module exports 3 functions: async, lock and unlock.

FUNCTIONS

#=head2 _create # #Internal use. #

async

This func is exported by default. It receives only one parameter, a sub_ref. It returns a thread::emulate::async object.

lock

This func is exported by default. It receives only one parameter, a reference for a shared var.

unlock

This func is exported by default. It receives only one parameter, a reference for a shared var.

AUTHOR

Fernando Correa de Oliveira, <fco at cpan.org>

BUGS

Please report any bugs or feature requests to bug-threads-emulate at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=threads-emulate. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc threads::emulate

You can also look for information at:

ACKNOWLEDGEMENTS

COPYRIGHT & LICENSE

Copyright 2009 Fernando Correa de Oliveira, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.