guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: The equivalent of racket's break-thread in guile?


From: Ludovic Courtès
Subject: Re: The equivalent of racket's break-thread in guile?
Date: Mon, 03 Jun 2013 12:12:56 +0200
User-agent: Gnus/5.130007 (Ma Gnus v0.7) Emacs/24.3 (gnu/linux)

Xin Wang <address@hidden> skribis:

> 2013/6/2 Ludovic Courtès <address@hidden>
>
>> Xin Wang <address@hidden> skribis:
>>
>> > 2013/5/31 Ludovic Courtès <address@hidden>
>> >
>> >> Xin Wang <address@hidden> skribis:
>> >>
>> >> > 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
>> >>
>> >> If I understand correctly, “breaks” are similar to Guile’s “asyncs”
>> >> (info "(guile) Asyncs").
>> >>
>> >> However, I don’t understand what you’re trying to achieve.  Could you
>> >> give another example of the behavior you’re after?
>> >>
>> >>
>> > I was reading source code of Arc language[1], and wondering if it is
>> > possible to port it to Guile.
>> >
>> > It define a function to handle HTTP request in srv.arc(L48):
>> >
>> > (def handle-request-1 (s)
>> >   --- pruned ---
>> >             (with (th1 nil th2 nil)
>> >               (= th1 (thread
>> >                        (after (handle-request-thread i o ip)
>> >                               (close i o)
>> >                               (kill-thread th2))))
>> >               (= th2 (thread
>> >                        (sleep threadlife*)
>> >                        (unless (dead th1)
>> >                          (prn "srv thread took too long for " ip))
>> >                        (break-thread th1)
>> >                        (force-close i o))))))))
>> >
>> > It create two threads to handle a request, one do main stuff and anthor
>> one
>> > wait to kill first one if it takes too much time.
>>
>> Here ‘break-thread’ in the first thread appears to be equivalent to
>> Guile’s ‘cancel-thread’.
>>
>
> Do you mean 'kill-thread' in the first thread?

Oh, yes, sorry for the confusion!

Ludo’.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]