Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Splitting large array for threads.

by Preceptor (Chaplain)
on Jun 18, 2014 at 16:59 UTC ( #1090321=note: print w/ replies, xml ) Need Help??


in reply to Splitting large array for threads.

A few points if I may?

  • Don't enqueue 'undef', use the 'end()' method to Thread::Queue. Much neater.
  • What are you trying to accomplish with 'pos'? Because it's a race condition. You lock it and update it, but a thread may - or may not - have already dequeued and read the variable .
  • You don't really need that 'eof' test, as it's implicit in reading 'FILE'. You might be better off with a while loop there.
  • 'use strict' is good. 'use warnings' is good too.

I can't see why your process would be stalling though. Usually I would look for an empty queue or a lock. Can I suggest inserting:

$Q -> pending();

Into that loop, for the sake of verification. My guess is that you might be getting tripped up by that 'sleep' call. But can't tell for sure, because it seems to work ok with an 1800 line file.


Comment on Re: Splitting large array for threads.
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1090321]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (16)
As of 2015-07-28 20:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (258 votes), past polls