Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

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

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

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 (Archbishop) on Feb 15, 2006 at 13: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 09: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
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2024-04-24 22:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found