Roman Klochkov <firstname.lastname@example.org>
|(require thread-utils)||package: thread-utils|
This package provides some utilities to do common patterns of async programming.
(until-timeout func [timeout on-error]) → any/c
func : (-> any/c)
timeout : (or/c #f (and/c real? (not/c negative?)) (-> any)) = 30 on-error : any/c = #f
Calls func and wait for answer not more then timeout. If func fails to complete until that moment and on-error is a procedure, then returns (on-error #f). If func raise an exception, applies on-error to the exception and returns it’s result. If on-error any other value, then it will be returned in case of error or timeout.
Returns thread, which runs func in infinite loop. When func raises an exception, applies on-error to the exception and run func again. If on-error is not a procedure, then errors are supressed.