Expand description
§libpetri-runtime — Petri Net Executors
Provides two executors for running Coloured Time Petri Nets defined with
libpetri-core.
§BitmapNetExecutor
The general-purpose executor. Single-threaded orchestrator with concurrent async actions.
§Execution Loop (5 phases per cycle)
- Process completed — collect outputs from finished async actions
- Process events — inject tokens from environment places
- Update dirty — re-evaluate enablement via bitmap masks (O(W) where W = ceil(places/64))
- Fire ready — sorted by priority, then FIFO by enablement time
- Await work — sleep until action completes, timer fires, or event arrives
§Key types
BitmapNetExecutor— the executorCompiledNet— precomputed bitmap masks and reverse indexesExecutorOptions— configuration (e.g. time source override)
§PrecompiledNetExecutor
A high-performance alternative optimized for throughput-critical workloads.
Additional optimizations over BitmapNetExecutor:
- Ring buffer token storage (flat
Vec<Option<ErasedToken>>pool) - Opcode-based consume dispatch (CONSUME_ONE, CONSUME_N, CONSUME_ALL, RESET)
- Two-level summary bitmaps for dirty/enabled iteration
- Reusable
HashMapbuffers reclaimed viatake_inputs()/take_reads() - Priority-partitioned ready queues
§Key types
PrecompiledNetExecutor— the executorPrecompiledNet— borrows&CompiledNet, zero-cost reuse
§Compilation Pipeline
PetriNet ──► CompiledNet ──► PrecompiledNet (optional)
(bitmap masks) (ring buffers, opcodes)§Marking
Marking holds the mutable token state — type-erased
FIFO queues per place, with typed access via Place<T> references.
§Async Support
Enable the tokio feature for run_async() on both executors. This allows
transition actions to be async (CompletableFuture-style) with external
event injection via environment places.