On 6/28/07, David Golden <[EMAIL PROTECTED]> wrote:
On 6/28/07, Eric Wilhelm <[EMAIL PROTECTED]> wrote:
> I was thinking there needs to be a shared filehandle with a stream of
> time on it similar to the below, but with various time() and sleep()
> methods overridden. Calls to time() or sleep() would peel-off lines,
> thus keeping everyone in sync. It becomes impossible for two things to
> happen at the same time (and I think I'm seeing the child blocking the
> parent's reads.
How about just having a file with a time offset? Use PERL5OPT to
automatically load up a module that overrides the various perl calls
to return the normal result of the call modified by the offset. As
long as you stay with Perl processes, that might be sufficient.
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.
Josh