mr_p has asked for the wisdom of the Perl Monks concerning the following question:

Hello,

Does anyone know if Threads::Queue::Any is safe to use, Currently I am using Threads::Queue and queuing a stiring with '|' delimited and spliting string after dequeing it.

Or can anyone think of better way to do this? I still would like to used Threads::Queue though.

#Master thread $str="abc|def|xyz"; enqueue($str) #a thread code dequeue($str) ($a,$b,$c)= split($str);

Replies are listed 'Best First'.
Re: Is this module safe to use -> Threads::Queue::Any
by BrowserUk (Patriarch) on Apr 16, 2010 at 16:02 UTC
    Currently I am using Threads::Queue and queuing a stiring with '|' delimited and spliting string after dequeing it.

    That's the way I would do it also. The time taken to join & split the string is negligable compared to the overhead of locking involved in the transfer of the string from one thread to another. And far less than the overhead involve in Thread::Queue::Any.

    It's simple. It works. And if things go wrong, it is easy to debug. Don't throw away that simplicity in search of something "more proper".

    You might consider using $; as your join/split delimiter. It is less likely to appear in your data than '|'.


    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.
      Thanks... for your reponse, I am not using join I am just using $str="abc|def|xyz";

      Also do you know how I can remove installed module?

        I am not using join I am just using $str="abc|def|xyz";

        At some point, if not already, 'abc', ''def' & 'xyz' won't be constants but rather contained in variables. At which point using $Q->enqueue( join $;, $abc, $def, $xyz ); starts to become prefereable.

        Also do you know how I can remove installed module?

        Depends how you installed it. If you used ppm/ppm-shell there is a 'remove' command. I don't think there is for cpan. If you did the 4-part mantra, then it would be a manual process.

        But there is no real reason to uninstall a module. Just stop using it. Next time you upgrade, you won't bother installing it. In the meantime, it just occupies a little disk.


        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.