hhmx.de

Föderation EN Di 14.01.2025 05:51:31

In a recent stream, I started using the Fibers library for Guile Scheme to learn more about how it enables Go-style concurrency in Scheme programs.

Here's a clip from that stream where I explain what Fibers is for, read through an example snippet using channels, and set up a basic HTTP request handler that uses Fibers' own server backend.

Let me know what you think about the clip format!

youtu.be/fYyZuYKjmWc

Föderation EN Di 14.01.2025 06:42:10

@daviwil fibers seem super neat! If anyone is interested in a coroutine event driven tool for Lua / Fennel check out cqueues.

Föderation EN Di 14.01.2025 14:53:42

@daviwil did you find any solution for the sqlite-in-fibers?

This kind of clips are really cool. You summarized everything pretty well!

Föderation EN Di 14.01.2025 15:28:16

@ekaitz_zarraga Thanks! The suggestion from @cbaines was to run the DB operations in a separate OS thread and use Fibers to queue up query operations via a channel.

Could work, but could also be a bottleneck. Interesting idea to try, though!

Föderation EN Di 14.01.2025 15:51:15

@daviwil @ekaitz_zarraga this is what I've done for several Guile+Fibers+SQLite projects over the last few years.

The key point is to allow the Fibers thread(s) to keep working while the database operations happen, which could include blocking I/O.

This all started with the Guix Build Coordinator, but the nar-herder has a slightly more readable implementation.

Föderation EN Di 14.01.2025 16:39:07

@cbaines @daviwil it makes sense, i was going to suggest something similar.

Föderation EN Di 14.01.2025 22:23:03

@daviwil

I just got a proof-of-concept going for using Fibers in Guile-Hoot. The clever piece is code by which allows for asynchronous messaging.

git.sr.ht/~afmoreno/tic-tac-to

Ping me if you have any questions