2013/5/31 Nala Ginrut <nalagin...@gmail.com> > On Fri, 2013-05-31 at 07:40 +0800, Xin Wang wrote: > > In Racket, break-thread is used to send an break exception to a > thread[1]. > > > > E. g. > > > > (let ((th (thread (lambda () > > (dynamic-wind > > (lambda () #t) > > (lambda () (/ 1 0)) > > (lambda () (sleep 5) (display "out-guard\n"))))))) > > > > (sleep 1) > > (break-thread th)) > > > > For above code, out-guard part of dynmaic-wind will not be interrupted if > > use break-thread to cancel a thread, and kill-thread will cancel thread > > immediately. > > > > In Guile, the equivalent of kill-thread is cancel-thread, and is there > any > > equivalent of break-thread? > > > > [1] http://docs.racket-lang.org/reference/breakhandler.html > > > > I think the answer is NO. > > The thread in Racket is green-thread which is implemented by some kind > of stack-copying. That's why its thread could receive the so-called > 'break signal'. The scheduler is in the VM rather than OS. > But the traditional thread in Guile is based on pthread. So they are > very different. > Anyway, I'm trying to write green-thread based on delimited-continuation > which will be used for an Actor-model implementation. > > Thank you for pointing out this.
After some more search, I found that pthread has function pthread_kill [1], which can be used to send signal to specific thread. No sure if it can be used to implement similar behaviour. [1] http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_kill.html > > > Regards, > > Xin Wang > > >