in reply to Re^3: LWP, DBI and Free to Wrong Pool error
in thread LWP, DBI and Free to Wrong Pool error

Many thanks kind monk, that certaintainly did solve the problem. Not only that it runs twice as fast. Well OK maybe that's an exaggeration, but it's a lot faster.

The only problem seems to be that it doesn't exit when the queue is empty. Does $running perhaps need to be modified inside the loop? I'm not sure because I don't really understand how the statement $running : shared = 0; works. Is the colon a conditional operator or does it tie $running to something in threads::shared?

Steve

Replies are listed 'Best First'.
Re^5: LWP, DBI and Free to Wrong Pool error
by BrowserUk (Patriarch) on Apr 29, 2007 at 00:29 UTC

    Check the loop condition, I just moved the sleep. That may not be the only logic error. It was a mind-only exercise and in between watching a movie to boot.

    Is the colon ... or does it tie $running to something in threads::shared?

    Yes. It makes $running shared by all threads. If you look at the top and bottom of thread(), you'll see that when a thread starts, it increments that variable. And decrements it when it finishes. The upshot is that when all the threads have finished, because they have exhausted the in-bound $Qwork od item to fetch, $running drops to zero and the main thread will see that and terminate.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.