chickadee » srfi-18 » thread-yield!

thread-yield!procedure

The current thread exits the running state as if its quantum had expired. thread-yield! returns an unspecified value.

    ; a busy loop that avoids being too wasteful of the CPU
 
    (let loop ()
      (if (mutex-lock! m 0) ; try to lock m but don't block
          (begin
            (display "locked mutex m")
            (mutex-unlock! m))
          (begin
            (do-something-else)
            (thread-yield!) ; relinquish rest of quantum
            (loop))))