jac-concurrency

Implements parallel and asynchronous execution in Jac using flow/wait and async/await.

Updated Jul 26, 2026
One-click install
npx skills add https://github.com/PMN123/trapdoor --skill jac-concurrency-pmn123
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: jac-concurrency
Source: https://github.com/PMN123/trapdoor/tree/main/.agents/skills/jac-concurrency
Command: npx skills add https://github.com/PMN123/trapdoor --skill jac-concurrency-pmn123

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing concurrent Jac code requires choosing between two different concurrency models, and picking the wrong one serializes work or produces invalid syntax. This Skill explains Jac's flow/wait thread-pool model and async def/await asyncio model so parallel and asynchronous code runs correctly the first time. ## Core Features & Use Cases - flow/wait parallelism: Launch blocking or CPU-bound functions on a thread pool with flow, then collect results with wait, using the launch-all-then-wait-all pattern to avoid accidental serialization. - async/await asyncio interop: Write async def functions, use asyncio.gather and asyncio.run, and declare async walkers whose abilities await I/O during graph traversal. - Model selection guidance: A decision table maps workload types (CPU-bound vs I/O-bound, HTTP/DB/LLM calls) to the right concurrency model, plus pitfalls like reserved keywords, await outside async def, and sendability rules for ownership-annotated payloads. - Use Case: You need to call an LLM for dozens of regulation clauses concurrently in a Jac backend; this Skill tells you to use async/await with an async client, or flow/wait for blocking calls, and how to structure the collect phase. ## Quick Start Ask the AI to write Jac code that runs several blocking function calls in parallel using flow and wait, then collects the results.

Frequently Asked Questions about jac-concurrency

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

FAQPage Schema
How do I run Jac functions in parallel?

Use flow to launch each call on a thread pool, which returns a future immediately, then use wait to collect results. Launch all flow expressions first and wait afterwards, since waiting right after each flow serializes the work.

What is the difference between flow/wait and async/await in Jac?

flow/wait uses a thread pool for true parallelism and suits CPU-bound or blocking synchronous calls. async/await is Python asyncio, cooperative and single-threaded, best for I/O-bound work like HTTP, database, or LLM calls with async libraries.

Can Jac walkers be async?

Yes. Declare an async walker with async abilities, then await the spawn from an async context. The traversal yields at each await instead of blocking, which suits walkers that fetch data per node.

Why does my Jac async code fail with await outside async def?

await is only valid inside an async def. From a top-level with entry block, drive async code by calling asyncio.run(main()) instead of awaiting directly.

Why is my Jac parallel code running serially with flow and wait?

Placing wait in the same loop body as flow serializes execution because each iteration blocks before launching the next task. Use two passes: launch all futures first, then wait for all of them.

Can ownership-annotated values cross a flow boundary in Jac?

Only sendable values can cross: scalars, imm values, or an own handle moved into the boundary. A live & or &mut borrow cannot cross, and moving an own Region handle is legal only while no borrows of it are live.