Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
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 chilling in the Monastery: (9)
As of 2014-08-21 21:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (143 votes), past polls