From: ludo@gnu.org (Ludovic Courtès)
To: Xin Wang <dram.wang@gmail.com>
Cc: Guile User <guile-user@gnu.org>
Subject: Re: The equivalent of racket's break-thread in guile?
Date: Mon, 03 Jun 2013 12:12:56 +0200 [thread overview]
Message-ID: <8738szh593.fsf@gnu.org> (raw)
In-Reply-To: <CAHjSAjUnRAecE+P9nq11sWpeXtWePOVKq8Y47_OnyYZLBwAvKA@mail.gmail.com> (Xin Wang's message of "Mon, 3 Jun 2013 09:37:45 +0800")
Xin Wang <dram.wang@gmail.com> skribis:
> 2013/6/2 Ludovic Courtès <ludo@gnu.org>
>
>> Xin Wang <dram.wang@gmail.com> skribis:
>>
>> > 2013/5/31 Ludovic Courtès <ludo@gnu.org>
>> >
>> >> Xin Wang <dram.wang@gmail.com> 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’.
next prev parent reply other threads:[~2013-06-03 10:12 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-30 23:40 The equivalent of racket's break-thread in guile? Xin Wang
2013-05-31 3:59 ` Nala Ginrut
2013-05-31 6:24 ` Xin Wang
2013-05-31 6:55 ` Nala Ginrut
2013-05-31 8:44 ` Xin Wang
2013-05-31 10:33 ` Xin Wang
2013-05-31 12:16 ` Chaos Eternal
2013-06-01 23:27 ` Xin Wang
2013-05-31 10:01 ` Ludovic Courtès
2013-06-01 23:49 ` Xin Wang
2013-06-02 0:34 ` Nala Ginrut
2013-06-02 1:11 ` Xin Wang
2013-06-02 13:51 ` Ludovic Courtès
2013-06-03 1:37 ` Xin Wang
2013-06-03 10:12 ` Ludovic Courtès [this message]
2013-05-31 11:20 ` Taylan Ulrich B.
2013-05-31 23:28 ` Thien-Thi Nguyen
2013-06-01 6:46 ` Taylan Ulrich B.
2013-06-01 16:08 ` Thien-Thi Nguyen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8738szh593.fsf@gnu.org \
--to=ludo@gnu.org \
--cc=dram.wang@gmail.com \
--cc=guile-user@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).