Can anybody give me any hints as to what I should be looking for? What
can cause sleep(0) to wake up?

I've got a thread that does

  loop do
    sleep(delay)

    ... do stuff, then set delay to 0 because there is no more work ...
    
    delay = 0
  end


And my loop is busy looping, sleep just won't!

Whether it does or not is triggered by changes in what appear to me to
be completely unrelated code. I'm mystified.

Thanks,
Sam