How fschuetz04/simgo works
Main components
a. Core Simulation Engine
• Simulation (simulation.go)
• EventQueue (eventqueue.go)
b. Process Management
• Process abstraction (process.go)
• Awaitable interface and combinators (awaitable.go, allof.go, anyof.go)
c. Event Abstraction
• Event (event.go)
• Timeout/Delay semantics (timeout created via proc.Timeout(...))
d. Resource & Store Modules
• Resource Manager (resource.go)
• Store Manager (store.go)
e. Public API Layer
• NewSimulation()
• ProcessReflect(...)
• RunUntil(...)
• Event() and Timeout(...)
f. User Code / Examples (_examples/…)
Relationships & data flows
• User code calls the API layer to
• Instantiate Simulation
• Register processes (ProcessReflect)
• Kick off the simulation (RunUntil)
• The Simulation holds a single EventQueue (a min-heap of future events).
• Each registered Process runs in its own goroutine but is *logically* single-threaded because the engine only *triggers* one event at a time.
• A process calls proc.Wait(...) on an Event or combinator; under the hood this:
• Wraps the waiting logic in an Awaitable
• Enqueues the event into the EventQueue
• The Simulation’s main loop:
1. Pop the next event from the EventQueue (earliest timestamp)
2. Advance the simulation clock to that time
3. Trigger that event → resume the waiting goroutine (Process)
• Resource Manager: processes request/release resources; if unavailable they get parked in a wait queue until another process calls Release
• Store Manager: Put/Get operations generate events when data becomes available or space frees up
Architectural patterns & design principles
• Event-driven core loop (single thread of control)
• Goroutine-per-process, but serial execution via explicit event triggers
• Heap-based priority queue for scheduling
• Combinator pattern for allOf/anyOf awaitables
• Modular design: core engine + pluggable resource/store modules + user API
Essential elements checklist
• All core Go modules (simulation.go, eventqueue.go, etc.)
• The main event loop and its interaction with Process and EventQueue
• The Resource and Store modules as separate components
• Public API functions as the “entry points”