From: Vincent Bernat <bernat@luffy.cx>
To: guile-user@gnu.org
Subject: guile and coroutines controlled from C
Date: Sat, 28 Jul 2012 19:29:26 +0200 [thread overview]
Message-ID: <m3pq7fn6a1.fsf@neo.luffy.cx> (raw)
Hi!
I would like to add Guile scripting to an actual program to allow a user
to write simple network-related scenarios. Those scenarios will be run
in parallel on several entities. The application is event-driven and I
want to hide this fact to the user. She should be able to write a
scenario in a simple blocking style:
#v+
(let ((v1 (do-something-blocking "arg1" "arg2"))
(v2 (do-something-blocking "arg3" "arg4")))
(when (< (+ v1 v2) 10) (...)))
#v-
`do-something-blocking` is a registered function written in C. I want to
be able to pause the execution inside this function and then resume it
later (when I my program got the data wanted by the user). In the
meantime, another "cooperative thread" may be executed.
In Lua, this is something that can be done with coroutines which can be
yield and resumed from C. In Guile, there are continuations but I have
hard time to understand how this should work from C.
What would be the equivalent of this in Guile?
http://kristianrumberg.wordpress.com/2010/11/21/135/
--
/*
* We used to try various strange things. Let's not.
*/
2.2.16 /usr/src/linux/fs/buffer.c
next reply other threads:[~2012-07-28 17:29 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-28 17:29 Vincent Bernat [this message]
2012-07-30 4:56 ` guile and coroutines controlled from C Ian Price
2012-07-30 5:38 ` Thien-Thi Nguyen
2012-08-01 13:15 ` Ian Price
2012-07-30 6:28 ` Vincent Bernat
2012-08-01 13:13 ` Ian Price
2012-08-02 17:28 ` Vincent Bernat
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=m3pq7fn6a1.fsf@neo.luffy.cx \
--to=bernat@luffy.cx \
--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).