Thread::Isolate::Map - Map/link packages of one thread to many other threads.


Thread-Isolate documentation  | view source Contained in the Thread-Isolate distribution.

Index


NAME

Top

Thread::Isolate::Map - Map/link packages of one thread to many other threads.

DESCRIPTION

Top

The idea of this module is to map a package of one thread to many other threads, saving memory through many threads.

Thread::Isolate::Map supports map for SCALAR, ARRAY, HASH, HANDLE (IO) and CODE symbols.

USAGE

Top

  use Thread::Isolate ; ## Is recomended to load it before to save memory.
  use Thread::Isolate::Map ;

  my $thi = Thread::Isolate->new() ;

  $thi->eval(q`
    package Foo ;
      $FOOVAL = 0 ;
  `) ;

  my $thi1 = Thread::Isolate->new() ;
  my $thi2 = Thread::Isolate->new() ;

  $thi1->map_package('Foo',$thi) ;
  $thi2->map_package('Foo',$thi) ;

  $thi1->eval('$Foo::FOOVAL = 10 ;');  ## $FOOVAL is 10 now. (thi1)

  $thi2->eval('$Foo::FOOVAL += 10 ;'); ## $FOOVAL is 20 now. (thi2)

  $thi->eval('return $Foo::FOOVAL'); ## returns 20. (thi)




As you can see in the code above all the 3 threads share the same package, and the package symbols like $FOOVAL.

METHODS

Top

new (PACKAGE , THREAD)

Maps a local package to a thread package.

PACKAGE

The package to map.

THREAD

The Thread::Isolate object that has the real package.

scan_pack_entries ( THREAD? , PACKAGE , RECURSIVE )

Scan the symbol table entries of a package.

THREAD?

If defined will scan the package inside the thread.

PACKAGE

The package to scan.

RECURSIVE

If TRUE will do a recursive scan, getting symbols of sub-packages.

Mapping HANDLEs (IO)

Top

All the mapped HANDLEs (IO) will be automatically flushed ($| = 1), since is not possible to flush from an external thread, also will avoid lose of output data when the HANDLE is not closed explicity when the process goes out.

SEE ALSO

Top

Thread::Isolate, Thread::Isolate::Pool.

AUTHOR

Top

Graciliano M. P. <gmpassos@cpan.org>

I will appreciate any type of feedback (include your opinions and/or suggestions). ;-P

COPYRIGHT

Top


Thread-Isolate documentation  | view source Contained in the Thread-Isolate distribution.