Beefy Boxes and Bandwidth Generously Provided by pair Networks Bob
P is for Practical
 
PerlMonks  

threads::question: where is the threads->cancel() call?

by turo (Friar)
on Feb 15, 2006 at 07:27 UTC ( [id://530358]=perlquestion: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.

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

Hi Monks, i have a question for the annals of our monastery library.


Posix threads (defined at <pthread.h>) has a list of standard calls:

  • pthread_create
  • pthread_exit
  • pthread_join
  • pthread_detach
  • ...
  • pthread_cancel
Seems that Perl thread implementation only has the most useful calls; but, where is the pthread_cancel? ... how can I cancel the execution of a thread which is running from another thread? ... Is this possible?

I search on perlthrtut, the threads man pages, the pm::ssearch, even i didn't find it on the camel book ... somebody knows any form to cancel the execution of a thread? ...

thanks :)

perl -Te 'print map { chr((ord)-((10,20,2,7)[$i++])) } split //,"turo"'

Replies are listed 'Best First'.
Re: threads::question: where is the threads->cancel() call?
by zentara (Cardinal) on Feb 15, 2006 at 08:40 UTC
    I don't know about how pthreads.h fits into this, but if you want to cancel the execution of a thread, 1 way is to use a shared variable, and when the thread sees that shared variable set to it's cancel value, then "return" in the thread ( and join if not a detached thread).

    Maybe the pthread_cancel is used to abruptly terminate a thread, like when an 'exit' or 'exec' is called from some other sibling thread.


    I'm not really a human, but I play one on earth. flash japh

      yes, pthread_cancel, is like 'use the force' with any thread you've launched ... :-) ...


      The scheme of changing a shared variable, doesn't help all the times ...

      perl -Te 'print map { chr((ord)-((10,20,2,7)[$i++])) } split //,"turo"'
Re: threads::question: where is the threads->cancel() call?
by Anonymous Monk on Feb 16, 2006 at 04:02 UTC
    Perl threads aren't posix threads

      I know that, (perl is supported over windows too)

      Even in that case, perl was born on a unix environment, and I can't believe we can't force a thread to finalize from another thread...

      turo

      perl -Te 'print map { chr((ord)-((10,20,2,7)[$i++])) } split //,"turo"'

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://530358]
Approved by Corion
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.