concurrent event simulation engine
A single-threaded event loop coordinates all concurrent activities, dispatching messages to actors and scheduling timer callbacks with microsecond precision. The loop never blocks -- every I/O operation is non-blocking, every computation is bounded.
Every concurrent entity is an actor with private state, a mailbox, and a behavior function. Actors communicate exclusively through asynchronous message passing -- no shared memory, no locks, no data races by construction.
import concengine as ce // Create engine with 4 workers engine := ce.NewEngine(ce.Workers(4)) // Define actor behavior counter := ce.Actor(func(msg ce.Message) { state.Update("count", state.Get("count") + 1) msg.Reply(state) }) // Spawn 1000 actors concurrently actors := engine.SpawnN(counter, 1000) engine.Run()
Messages are immutable, typed, and delivered in causal order. The engine guarantees that messages between any two actors arrive in the order they were sent. Broadcast, multicast, and point-to-point delivery patterns are all first-class operations.