async-io-model

Manage Turso I/O-bound operations with cooperative yielding and explicit state machines.

23.8k|1.2k|Updated Aug 26, 2023
One-click install
npx skills add https://github.com/tursodatabase/turso --skill async-io-model
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: async-io-model
Source: https://github.com/tursodatabase/turso/tree/main/.claude/skills/async-io-model
Command: npx skills add https://github.com/tursodatabase/turso --skill async-io-model

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Turso's asynchronous I/O model uses cooperative yielding and explicit state machines to manage I/O-bound tasks without Rust's async/await, reducing re-entrancy bugs and making IO progress deterministic.

Core Features & Use Cases

  • IOResult and IOCompletions as the primitive for non-blocking operations.
  • CompletionGroup to aggregate multiple IOs into a single completion with cancellation support.
  • return_if_io! and io_yield_one! macros to manage yields and resumes safely.
  • State-machine driven operation patterns to prevent re-entry bugs across core storage and IO layers (btree, pager, and utilities).
  • Re-entrancy hazard awareness and best practices for mutating state only after IO completion.

Quick Start

To get started, study the Core Types, Completion structures, and State Machine patterns described above, then implement a tiny operation that yields once and resumes to completion. You can adapt this to a simple read workflow in core/storage/btree.rs or core/storage/pager.rs to see the patterns in action.

Frequently Asked Questions about async-io-model

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I manage non-blocking I/O operations in Rust without using async/await?

Manage non-blocking I/O operations without Rust async/await by using cooperative yielding and explicit state machines. This approach enforces IOResult and IOCompletions primitives to make IO progress deterministic and reduce re-entrancy bugs.

How do I prevent re-entrancy bugs during core storage reads and writes?

Prevent re-entrancy bugs during core storage reads and writes by adopting state-machine driven operation patterns. Mutate state only after IO completion and use return_if_io! and io_yield_one! macros to manage safe yields and resumes.

What is the best way to aggregate multiple I/O operations into a single completion?

Aggregate multiple I/O operations into a single completion by using CompletionGroup. This primitive provides built-in cancellation support, allowing you to manage grouped I/O-bound tasks efficiently within the core I/O layers.

How do I implement a basic yield and resume state machine for storage tasks?

Implement a basic yield and resume state machine by studying core types and completion structures, then writing a tiny operation that yields once using io_yield_one! and resumes to completion. Adapt this pattern to read workflows in btree or pager modules.

When should I use cooperative yielding instead of standard Rust async for I/O-bound tasks?

Use cooperative yielding instead of standard Rust async for I/O-bound tasks when deterministic IO progress and explicit state management are required. This approach avoids async/await complexity, directly addressing re-entrancy hazards across core storage and background maintenance operations.