jethro - thanks, I've thought about it, but not as deep as needed! :)
BrowserUk - I am very pleased that an expert in threading tries to help me! But can you tell more about some lines of your code:
At a first look I thought that you code is placing all lines of file in queue in one time. But when I changed
printf "%3d: (%10d, %10d) :%s", $tid, $pos, $size, $line;
to
printf "%3d: (%10d, %10d, %10d) :%s", $tid, $pos, $size, $Q->pending, $line;
I saw that I wasn't right in my conclusion.
So, can you explain - how code in block "while( !eof FILE ) {" interacts with code in thread sub in just the right way? It is placed outside the sub. Or the trick is that you placed the join procedure only after the while loop, not just after the 'create' sub?
Yes, I made a mistake when wrote my own proc with reading a lines with binary access, I've just forgot about the 'tell' function.
Why 'abs($threadscnt-1)'? Because I was taught to make all my programs with even though dawns of 'fool-proof' input.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.