Thread::Apartment

Thread::Apartment is an apartment threading wrapper for Perl objects.
Download

Thread::Apartment Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Dean Arnold
  • Publisher web site:
  • http://search.cpan.org/~darnold/

Thread::Apartment Tags


Thread::Apartment Description

Thread::Apartment is an apartment threading wrapper for Perl objects. Thread::Apartment is an apartment threading wrapper for Perl objects.SYNOPSIS package MyClass; use Thread::Apartment::Server; use base qw(Thread::Apartment::Server); sub new { # # the usual constructor # } # # mark some methods as simplex # sub get_simplex_methods { return { 'bar' => 1 }; } # # mark some methods as urgent # sub get_urgent_methods { return { 'bingo' => 1 }; } sub foo { # # do something # } sub bar { # # do something else # } sub bingo { print "BINGO!n"; } 1; # # create pool of 20 apartment threads # Thread::Apartment->create_pool(AptPoolSize => 20); my $apt = Thread::Apartment->new( AptClass => 'MyClass', # class to install in apartment AptTimeout => 10, # timeout secs for TQD responses AptRequire => { # classes to require into the thread 'This::Class' => '1.234', 'That::Class' => '0.02' }, AptParams => @params_for_MyClass) || die $@; my $result = $apt->foo(@params); die $@ unless $result; # # bar is simplex # $apt->bar(@params);Thread::Apartment provides an apartment threading wrapper for Perl classes. "Apartment threading" is a method for isolating an object (or object hierarchy) in its own thread, and providing external interfaces via lightweight client proxy objects. This approach is especially valuable in the Perl threads environment, which doesn't provide a direct means of passing complex, nested structure objects between threads, and for non-threadsafe legacy object architectures, e.g., Perl/Tk.By using lightweight client proxy objects that implement the Thread::Queue::Queueable interface, with Thread::Queue::Duplex objects as the communication channel between client proxies and apartment threads (or between threads in general), a more thread-friendly OO environment is provided, ala Java, i.e., the ability to pass arbitrary objects between arbitrary threads. Requirements: · Perl


Thread::Apartment Related Software