guile-user
[Top][All Lists]
Advanced

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

guile and coroutines controlled from C


From: Vincent Bernat
Subject: guile and coroutines controlled from C
Date: Sat, 28 Jul 2012 19:29:26 +0200
User-agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.1 (gnu/linux)

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



reply via email to

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