Coro::Localize

Localize variables to a coroutine
Download

Coro::Localize Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Rebecca Turner
  • Publisher web site:
  • http://search.cpan.org/~winter/

Coro::Localize Tags


Coro::Localize Description

Coro::Localize provides a new keyword, "corolocal" that works will localize a variable to a particular coroutine. This allows you to have thread-local values for global variables. It can localize scalars, arrays and hashes.SYNOPSIS use feature qw( say ); use Coro; use Coro::EV; use Coro::Localize; # Or with Syntax::Feature: # use syntax qw( corolocal ); our $scalar = "main loop"; async { corolocal $scalar = "thread 1"; say "# 1 - $scalar"; cede; say "# 3 - $scalar"; cede; say "# 5 - $scalar"; }; async { corolocal $scalar = "thread 2"; say "# 2 - $scalar"; cede; say "# 4 - $scalar"; cede; say "# 6 - $scalar"; }; say "# starting $scalar"; EV::loop; say "# complete $scalar";# Will print: # starting main loop # 1 - thread 1 # 2 - thread 2 # 3 - thread 1 # 4 - thread 2 # 5 - thread 1 # 6 - thread 2 # complete main loopProduct's homepage


Coro::Localize Related Software