From 904526129a2377306a735c73b26699583b3b99c5 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 26 May 2010 22:49:49 +0000 Subject: thread_spawn: document why we sleep instead of Thread.pass --- lib/rainbows/thread_spawn.rb | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib/rainbows/thread_spawn.rb') diff --git a/lib/rainbows/thread_spawn.rb b/lib/rainbows/thread_spawn.rb index 75cc150..9660fc0 100644 --- a/lib/rainbows/thread_spawn.rb +++ b/lib/rainbows/thread_spawn.rb @@ -33,6 +33,9 @@ module Rainbows # synchronization primitives for _every_ case, not just this # unlikely one. Since this case is (or should be) uncommon, # just busy wait when we have to. + # We don't use Thread.pass because it needlessly spins the + # CPU during I/O wait, CPU cycles that can be better used + # by other worker _processes_. sleep(0.01) elsif c = Rainbows.sync_accept(l) klass.new(c) do |c| -- cgit v1.2.3-24-ge0c7