Skip to content

Instantly share code, notes, and snippets.

@sue445
Last active August 29, 2015 14:15
Show Gist options
  • Save sue445/2c658c936e5aa9d9a7d4 to your computer and use it in GitHub Desktop.
Save sue445/2c658c936e5aa9d9a7d4 to your computer and use it in GitHub Desktop.
sleepで指定した秒数だけsleepされるわけではない
irb(main):001:0> ret = sleep 0.1
#=> 0
irb(main):002:0> ret = sleep 1.5
#=> 2
EXISTS_USLEEP = `which usleep`.length > 0
def usleep(sec)
return if sec == 0
if EXISTS_USLEEP
msec = sec * 1000000
system "usleep #{msec.to_i}"
else
# usleepが無い場合は普通のsleep
sleep sec
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment