<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,16 +1,16 @@
 class Semaphore
   def initialize(resource_count = 0)
-    @available_resource_count = resource_count
+    @available_resource_count = resource_count.to_i
     @mutex = Mutex.new
     @waiting_threads = []
   end
   
   def wait
-    make_thread_wait unless resource_is_available
+    sleep_thread unless available_resource?
   end
   
   def signal
-    schedule_waiting_thread if thread_is_waiting
+    schedule_waiting_thread if waiting_thread?
   end
   
   def synchronize
@@ -22,18 +22,18 @@ class Semaphore
   
   private 
   
-  def resource_is_available
+  def available_resource?
     @mutex.synchronize do
       return (@available_resource_count -= 1) &gt;= 0
     end
   end
   
-  def make_thread_wait
+  def sleep_thread
     @waiting_threads &lt;&lt; Thread.current
     Thread.stop  
   end
   
-  def thread_is_waiting
+  def waiting_thread?
     @mutex.synchronize do
       return (@available_resource_count += 1) &lt;= 0
     end</diff>
      <filename>lib/mongrel/semaphore.rb</filename>
    </modified>
    <modified>
      <diff>@@ -110,6 +110,18 @@ class TestSemaphore &lt; Test::Unit::TestCase
     assert_equal 3, run_count
   end
   
+  def test_semaphore_with_several_available_resources_schedules_several_threads
+    @semaphore = Semaphore.new(4)
+    active = [false, false, false, false]
+    4.times do |i|
+      thread = Thread.new { @semaphore.synchronize { active[i] = true } }
+    end
+    give_up_my_time_slice
+    @semaphore.wait
+    
+    assert active.all?
+  end
+  
   private 
   
   def give_up_my_time_slice</diff>
      <filename>test/unit/test_semaphore.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>5915b8af83b1d191ecabde76da56932cc08c107a</id>
    </parent>
  </parents>
  <author>
    <name>Pivotal  Labs</name>
    <email>pivotal@cumberland.flood.pivotallabs.com</email>
  </author>
  <url>http://github.com/pivotal/mongrel/commit/c48230d78ccb099eb901e6241227363d3b21c27d</url>
  <id>c48230d78ccb099eb901e6241227363d3b21c27d</id>
  <committed-date>2008-08-27T18:39:11-07:00</committed-date>
  <authored-date>2008-08-27T18:39:11-07:00</authored-date>
  <message>ssuring resource_count is an int</message>
  <tree>f0413bdd88a33e0239a01e84f3ea616b46952405</tree>
  <committer>
    <name>Pivotal  Labs</name>
    <email>pivotal@cumberland.flood.pivotallabs.com</email>
  </committer>
</commit>
