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

Re: Perl how to join all threads

by Anonymous Monk
on Jul 06, 2015 at 21:27 UTC ( [id://1133450]=note: print w/replies, xml ) Need Help??


in reply to Perl how to join all threads

What are the threads doing?

I'd ignore all signals instead of trying to join inside a sighandler

Signals and threading do not mix;

Replies are listed 'Best First'.
Re^2: Perl how to join all threads
by kamrul (Acolyte) on Jul 06, 2015 at 21:52 UTC
    Hi.. thanks for your reply. I just found the problem is causing due to one thread. I have no problem if I turn that off. The function proc1 is using Thread::Queue. I tested without proc1 and it doesnt create any problem. Code of proc1 is like the below:
    sub proc1 { $q = Thread::Queue->new(); while($p = $q->dequeue()){ if($p eq 'exit'){ last; } ..... } $q->end(); threads->exit(); }

      This: $q->dequeue() blocks internally on a cond_wait(), if no data is available in the queue. Signals will not interrupt threads::cond_wait().

      That said, how will that queue ever receive anything?

      It is created inside the thread and immediately goes into a dequeue(). As it was created inside the thread, no other thread has a handle to it, so no data can ever be queued to it.

      Your design is broken.


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      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.
      I'm with torvalds on this Agile (and TDD) debunked I told'em LLVM was the way to go. But did they listen!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1133450]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2024-04-19 22:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found