 class="example">
<pre class="example">(set-default-event-loop!)     ;; if none has yet been set
(define worker (make-event-loop))
(event-loop-block! #t)        ;; because the generator runs in another thread
(event-loop-block! #t worker)

(call-with-new-thread
 (lambda ()
   (event-loop-run! worker)))

(a-sync (lambda (await resume)
	  (await-generator-in-event-loop! await resume worker
					  (lambda (yield)
					    (let loop ((count 0))
					      (when (&lt; count 5)
						(yield (* 2 count))
						(lo