I want to play around with the 8sync framework, but the project is unfortunately lacking an API reference. So, I am writing example code to help me learn each of the modules, and thought I might as well share. Here is some example code for the (8sync agenda) module.
(define-module (8sync agenda examples))
(use-modules (8sync agenda)
(srfi srfi-26)
(srfi srfi-31))
(export make-stuff)
(define (make-something thing amt)
((rec (l n)
(when (positive? n)
(display "Making ") (display thing) (display "\n")
(8yield)
(l (- n 1)))) amt))
(define (make-stuff)
(define my-agenda
(make-agenda
#:queue (make-q* (cut make-something "widget" 10)
(cut make-something "thingamabob" 5)
(cut make-something "sprocket" 5))))
(run-agenda my-agenda))
This illustrates how an Agenda can be used to interweave the execution of computations, by yielding to other computations during your loop:
scheme@(guile-user)> ,use (8sync agenda examples)
scheme@(guile-user)> (make-stuff)
Making widget
Making thingamabob
Making sprocket
Making widget
Making thingamabob
Making sprocket
Making widget
Making thingamabob
Making sprocket
Making widget
Making thingamabob
Making sprocket
Making widget
Making thingamabob
Making sprocket
Making widget
Making widget
Making widget
Making widget
Making widget
$2 = done