Add timeout mechanism for time-limited function calls