On Jun 28, 2007, at 10:30 PM, Joshua ben Jore wrote:
I had a terrible and powerful idea just now. Use Runops::Trace to
provide op-level synchronization points. You could have N threads or
processes all doing their individual ops (or statements if you prefer
that granularity) in an order that you prefer. You'd have each process
or thread do blocking reads off some socket or whatever and your
central program with the master script would tell each one when it's
ok to run an op. Heck... you could make it bi-directional and have the
children send their current op up to the master script so it could
even make decisions about it.
This is such a sweet idea, I might actually want to try threads just
to play with it.
The module isn't threadsafe but that's only because I didn't try to
make it so. Perhaps it isn't too difficult to do that for it.
I think it would be better to implement this with ordinary thread
locking instead of a core hack. Something like this would do the trick:
http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/
CyclicBarrier.html
Perl thread locking:
http://search.cpan.org/~nwclark/perl-5.8.8/lib/Thread/Semaphore.pm
http://search.cpan.org/~nwclark/perl-5.8.8/pod/
perlthrtut.pod#Synchronization_and_control
And just to tease Josh a little:
http://www.everything2.com/index.pl?node_id=987739
Chris
--
Chris Dolan, Equilibrious LLC, http://equilibrious.net/
Public key: http://chrisdolan.net/public.key
vCard: http://chrisdolan.net/ChrisDolan.vcf