Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
while ( my $bl = $$q->dequeue_nb()){

There is almost no reason to ever use ->dequeue_nb() in a worker thread. Enqueue undef to tell a worker thread to quit, and enqueue a value (or an arrayref of values for bulk processing) when the worker should do something.

sub slurp_directory_as_bin{ ...

Personally, if you have that many files, I would consider to either store all the file names in a database, or to spawn an external process (like ls -lR or dir /b /s) to read in all the filenames. With the database you get more flexibility to slice and dice your dataset, and if it doesn't change (that often), having convenient access makes all the other things more convenient too. With the external process, you can start processing the first files in the "directory reader thread" while it still reads in more files.


In reply to Re: Threads slurping a directory and processing before conclusion by Corion
in thread Threads slurping a directory and processing before conclusion by TRoderic

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (3)
As of 2024-04-26 03:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found