Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Splitting large array for threads.

by Preceptor (Deacon)
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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1090321]
help
Chatterbox?
and John Coltrane plays...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2017-12-17 14:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (464 votes). Check out past polls.

    Notices?