<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -92,10 +92,10 @@ class ServerTest
     case name
     when 'emongrel'
       @pid = fork { start_emongrel }
-    when /^ebb(\d*)$/
-      workers = $1.to_i
-      workers = 1 if workers &lt;= 0
-      @pid = fork { start_ebb(workers) }
+    when 'ebb_threaded'
+      @pid = fork { start_ebb_threaded }
+    when 'ebb_sequential'
+      @pid = fork { start_ebb_sequential }
     when 'mongrel'
       @pid = fork { start_mongrel }
     when 'thin'
@@ -116,9 +116,14 @@ class ServerTest
     Rack::Handler::Mongrel.run(app, :Host =&gt; '0.0.0.0', :Port =&gt; @port.to_i)
   end
   
-  def start_ebb(workers = 1)
+  def start_ebb_threaded
     require File.dirname(__FILE__) + '/../ruby_lib/ebb'
-    server = Ebb::start_server(app, :port =&gt; @port, :workers =&gt; workers)
+    server = Ebb::start_server(app, :port =&gt; @port, :threaded_processing =&gt; true)
+  end
+
+  def start_ebb_sequential
+    require File.dirname(__FILE__) + '/../ruby_lib/ebb'
+    server = Ebb::start_server(app, :port =&gt; @port, :threaded_processing =&gt; false)
   end
   
   def start_mongrel</diff>
      <filename>benchmark/server_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -9,18 +9,28 @@ module Ebb
   
   def self.start_server(app, options={})
     port = (options[:port] || 4001).to_i
-    FFI::server_listen_on_port(port)
+    if options.has_key?(:threaded_processing)
+      threaded_processing = options[:threaded_processing] ? true : false
+    else
+      threaded_processing = true
+    end
     
-    puts &quot;Ebb listening at http://0.0.0.0:#{port}/&quot;
+    Client::BASE_ENV['rack.multithread'] = threaded_processing
+    
+    FFI::server_listen_on_port(port)
     
+    puts &quot;Ebb listening at http://0.0.0.0:#{port}/ (#{threaded_processing ? 'threaded' : 'sequential'} processing)&quot;
     trap('INT')  { @running = false }
     @running = true
     
     while @running
       FFI::server_process_connections()
       while client = FFI::waiting_clients.shift
-        #process_client(app, client)
-        Thread.new(client) { |c| c.process(app) }
+        if threaded_processing
+          Thread.new(client) { |c| c.process(app) }
+        else
+          client.process(app)
+        end
       end
     end
     
@@ -157,4 +167,4 @@ module Ebb
     504  =&gt; 'Gateway Time-out', 
     505  =&gt; 'HTTP Version not supported'
   }.freeze
-end
\ No newline at end of file
+end</diff>
      <filename>ruby_lib/ebb.rb</filename>
    </modified>
    <modified>
      <diff>@@ -23,7 +23,8 @@ module Ebb
     DEFAULT_OPTIONS = {
       :port         =&gt; 4001,
       :timeout      =&gt; 60,
-      :workers      =&gt; 1
+      :workers      =&gt; 1,
+      :threaded_processing =&gt; true
     }
     
     # Kill the process which PID is stored in +pid_file+.
@@ -119,6 +120,12 @@ module Ebb
         parser.on(&quot;-P&quot;, &quot;--pid-file FILE&quot;, &quot;File to store PID&quot;) { |f| options[:pid_file]=f }
         parser.on(&quot;-t&quot;, &quot;--timeout SECONDS&quot;, &quot;(default: #{options[:timeout]})&quot;) { |s| options[:timeout]=s }
         #parser.on(&quot;-w&quot;, &quot;--workers WORKERS&quot;, &quot;Number of worker threads (default: #{options[:workers]})&quot;) { |w| options[:workers]=w }
+        parser.on(&quot;-w&quot;, &quot;-- WORKERS&quot;, &quot;Number of worker threads (default: #{options[:workers]})&quot;) { |w| options[:workers]=w }
+        
+        parser.on(&quot;-S&quot;, &quot;--sequential&quot;, &quot;do not use threaded processing&quot;) do
+          options[:threaded_processing] = false
+        end
+        
         parser.separator &quot;&quot;
         parser.on_tail(&quot;-h&quot;, &quot;--help&quot;, &quot;Show this message&quot;) do
           puts parser</diff>
      <filename>ruby_lib/ebb/runner.rb</filename>
    </modified>
    <modified>
      <diff>@@ -58,14 +58,17 @@ VALUE server_process_connections(VALUE _)
 {
   ev_timer timeout;
   ev_timer_init (&amp;timeout, oneshot_timeout, 0.01, 0.);
-  ev_timer_start (loop, &amp;timeout);
-   
+  ev_timer_start (loop, &amp;timeout); 
   ev_loop(loop, EVLOOP_ONESHOT);
-  /* XXX: Need way to know when the loop is finished...
-   * should return true or false */
-   
   ev_timer_stop(loop, &amp;timeout);
   
+  /* Call rb_thread_schedule() proportional to the number of rb threads running */
+  /* SO HACKY! Anyone have a better way to do this? */
+  int i;
+  for(i = 0; i &lt; EBB_MAX_CLIENTS; i++)
+    if(server-&gt;clients[i].in_use)
+      rb_thread_schedule();
+  
   if(server-&gt;open)
     return Qtrue;
   else</diff>
      <filename>src/ebb_ruby.c</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>274c811b4e810134dbfb118402190151cc752688</id>
    </parent>
  </parents>
  <author>
    <name>Ryan Dahl</name>
    <email>ry@lakshmi.local</email>
  </author>
  <url>http://github.com/ry/ebb/commit/023a85c3083bea17375f24c751af8fd97214b8ba</url>
  <id>023a85c3083bea17375f24c751af8fd97214b8ba</id>
  <committed-date>2008-03-11T10:09:51-07:00</committed-date>
  <authored-date>2008-03-11T10:09:51-07:00</authored-date>
  <message>Add rb_thread_schedule() and threaded_processing option

This change should allow Ebb to work like mongrel with threaded processing or like Thin with sequential processing. There are trade off for each, thus i've made it a command line option '-S'

By default Ebb will use threaded processing because it seems that is working best. But only time will tell if that is the correction thing to do.</message>
  <tree>a6f528c056a1c6aa59c5f9a74bc8c12e5f84da5b</tree>
  <committer>
    <name>Ryan Dahl</name>
    <email>ry@lakshmi.local</email>
  </committer>
</commit>
