<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/asynchronous-state-machines-with-fibers-v6oun3cal" -->

---
title: Asynchronous State Machines with Fibers | daily.dev
description: Explores using GNOME&#x27;s libdex primitives—DexLimiter and DexFiber—to implement asynchronous state machines more cleanly than chains of callbacks. Using a...
canonical: https://daily.dev/posts/asynchronous-state-machines-with-fibers-v6oun3cal
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Asynchronous State Machines with Fibers | daily.dev
og:description: Explores using GNOME&#x27;s libdex primitives—DexLimiter and DexFiber—to implement asynchronous state machines more cleanly than chains of callbacks. Using a...
og:url: https://daily.dev/posts/asynchronous-state-machines-with-fibers-v6oun3cal
og:image: https://api.daily.dev/og/posts/V6oUn3cal.png
og:image:alt: Asynchronous State Machines with Fibers
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Asynchronous State Machines with Fibers

**[Happenings in GNOME](https://daily.dev/sources/chergert)** · 3 min read · 0 upvotes · 0 comments

## Summary

Explores using GNOME's libdex primitives—DexLimiter and DexFiber—to implement asynchronous state machines more cleanly than chains of callbacks. Using a limiter with max concurrency of 1 acts as an asynchronous mutex, letting fiber-based transition functions await asynchronous work while keeping state machine logic in one place, avoiding scattered temporary state and untested failure paths common in callback-based designs.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://blogs.gnome.org/chergert/2026/06/21/asynchronous-state-machines-with-fibers>

## Questions this post answers

### How can I implement an asynchronous mutex in C using libdex?

Use a DexLimiter with a max concurrency of 1, which acts as an asynchronous mutex without manual lock management. Call dex_limiter_new(1) to create it, then run work through dex_limiter_run() passing a fiber function and closure; the fiber only spawns once it becomes the highest priority runnable slot.

_Developers designing async daemons compare concurrency primitives like this one on daily.dev._

### Why should I use a state machine instead of chained callbacks for async workflows in GTK or daemon code?

State machines built with libdex fibers keep all transition logic in one place, letting you use dex_await() to wait on futures inline instead of scattering temporary state across callback closures. This avoids missed failure cases, ordering bugs in the main loop, and the testing difficulty that comes with ad-hoc chained callbacks.

_Engineers weighing async design patterns track approaches like this on daily.dev._

---

Tags: [#c](https://daily.dev/tags/c)

[View this post on daily.dev](https://daily.dev/posts/asynchronous-state-machines-with-fibers-v6oun3cal)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Asynchronous State Machines with Fibers","url":"https://daily.dev/posts/asynchronous-state-machines-with-fibers-v6oun3cal","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/asynchronous-state-machines-with-fibers-v6oun3cal"},"datePublished":"2026-08-31T05:54:37.211Z","dateModified":"2026-08-31T05:55:45.458Z","description":"Explores using GNOME's libdex primitives—DexLimiter and DexFiber—to implement asynchronous state machines more cleanly than chains of callbacks. Using a...","image":"https://media.daily.dev/image/upload/s--VDukGCjf--/f_auto/v1722860399/public/Placeholder%2002","thumbnailUrl":"https://media.daily.dev/image/upload/s--VDukGCjf--/f_auto/v1722860399/public/Placeholder%2002","isAccessibleForFree":true,"articleSection":"Happenings in GNOME","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Happenings in GNOME","logo":"https://media.daily.dev/image/upload/logos/placeholder.jpg","url":"https://daily.dev/sources/chergert"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/asynchronous-state-machines-with-fibers-v6oun3cal","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"c","timeRequired":"PT3M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Happenings in GNOME","item":"https://daily.dev/sources/chergert"},{"@type":"ListItem","position":3,"name":"Asynchronous State Machines with Fibers"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/asynchronous-state-machines-with-fibers-v6oun3cal#faq","mainEntity":[{"@type":"Question","name":"How can I implement an asynchronous mutex in C using libdex?","acceptedAnswer":{"@type":"Answer","text":"Use a DexLimiter with a max concurrency of 1, which acts as an asynchronous mutex without manual lock management. Call dex_limiter_new(1) to create it, then run work through dex_limiter_run() passing a fiber function and closure; the fiber only spawns once it becomes the highest priority runnable slot. Developers designing async daemons compare concurrency primitives like this one on daily.dev."}},{"@type":"Question","name":"Why should I use a state machine instead of chained callbacks for async workflows in GTK or daemon code?","acceptedAnswer":{"@type":"Answer","text":"State machines built with libdex fibers keep all transition logic in one place, letting you use dex_await() to wait on futures inline instead of scattering temporary state across callback closures. This avoids missed failure cases, ordering bugs in the main loop, and the testing difficulty that comes with ad-hoc chained callbacks. Engineers weighing async design patterns track approaches like this on daily.dev."}}]}
```

