thread-utils
until-timeout
thread-loop
7.0

thread-utils

Roman Klochkov <[email protected]>

 (require thread-utils) package: thread-utils

This package provides some utilities to do common patterns of async programming.

procedure

(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 . -> . any/c)
Calls func and wait for answer not more then timeout. If func fails to complete until that moment, returns (in-error #f). If func raise an exception, applies on-error to the exception and returns it’s result.

procedure

(thread-loop func on-error)  thread?

  func : (-> any/c)
  on-error : (any/c . -> . any)
Returns thread, which runs func in infinite loop. When func raises an exception, applies on-error to the exception and run func again.