Sim
Sim

Reputation: 4184

how to properly wait for n seconds

I want to implement a function which waits n seconds before retrying in case of a failure, but what would be the proper way of implementing the waiting-routine.

I figured that an endless loop with an if-clause might cause unwanted CPU-usage.

(do ((time (+ (get-universal-time) (- n 1)))
     (time-cur (get-universal-time) (get-universal-time)))
    ((< time time-cur) nil))

Therefore: Would this be considered proper code or is there a more standard way?

Upvotes: 4

Views: 1510

Answers (1)

Vsevolod Dyomkin
Vsevolod Dyomkin

Reputation: 9451

Isn't SLEEP what your're looking for?

Upvotes: 6

Related Questions