Data-processing and flow-control engine for event-driven programs