Pass around a time constraints object rather than a timeout in millis for more flexibility as well as type safety.