withTimeout

inline fun <T> withTimeout(block: () -> T): T

Surrounds block with calls to enter and exit, throwing an exception from newTimeoutException if a timeout occurred.