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

Version 0.0.4

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... :) )

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

#=head2 _create # #Internal use. #
This func is exported by default. It receives only one parameter, a sub_ref. It returns a thread::emulate::async object.
This func is exported by default. It receives only one parameter, a reference for a shared var.
This func is exported by default. It receives only one parameter, a reference for a shared var.

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

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.

You can find documentation for this module with the perldoc command.
perldoc threads::emulate
You can also look for information at:


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.