good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
We could reduce your question to: Why does using subroutines make code simple? We are looking at two very different functions. It is logical to split them and keep two simple easy to debug blocks, rather than interleave them in a complex routine. Depending on the simplicity of the records going to <STDOUT> it may even be better to have the workers print directly. If the records are long and will not print as an atomic operation, or if there is post processing, then an publishing thread that gathers them and prints them keeps this work in one place. Something like this looks very simple to me.
Do you have an example where you read <STDIN> and the $result queue in the same code block, that is simpler? Now if we need to add pre or post processing then it sits nicely in the dispatcher or publisher routine without being all mixed up. Cheers,
Pereant, qui ante nos nostra dixerunt!
In reply to Re^5: Threading with a twist
by Random_Walk
|
|