libpetri-runtime 1.4.0

Bitmap executor runtime for libpetri Coloured Time Petri Net engine
Documentation

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)

  1. Process completed — collect outputs from finished async actions
  2. Process events — inject tokens from environment places
  3. Update dirty — re-evaluate enablement via bitmap masks (O(W) where W = ceil(places/64))
  4. Fire ready — sorted by priority, then FIFO by enablement time
  5. Await work — sleep until action completes, timer fires, or event arrives

Key types

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 HashMap buffers reclaimed via take_inputs()/take_reads()
  • Priority-partitioned ready queues

Key types

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.