diff options
author | Eric Wong <normalperson@yhbt.net> | 2009-02-05 00:50:52 -0800 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2009-02-09 19:50:37 -0800 |
commit | 2dddf957462f2cdbd6f141f35e0292a70b62c5a6 (patch) | |
tree | 2159a3233048cd84e7147572380f090ad22491a3 /lib/unicorn | |
parent | 28d571b7cca709641d964e00e6004facb6bfcc7e (diff) | |
download | unicorn-2dddf957462f2cdbd6f141f35e0292a70b62c5a6.tar.gz |
All tests for threading and semaphores have been removed. One test was changed because it depended on a shared variable. Tests will be replaced with tests to do process management instead.
Diffstat (limited to 'lib/unicorn')
-rw-r--r-- | lib/unicorn/http_request.rb | 4 | ||||
-rw-r--r-- | lib/unicorn/semaphore.rb | 46 |
2 files changed, 2 insertions, 48 deletions
diff --git a/lib/unicorn/http_request.rb b/lib/unicorn/http_request.rb index a76d4e0..f70f0de 100644 --- a/lib/unicorn/http_request.rb +++ b/lib/unicorn/http_request.rb @@ -54,8 +54,8 @@ module Unicorn "rack.input" => @body, "rack.errors" => STDERR, - "rack.multithread" => true, - "rack.multiprocess" => false, # ??? + "rack.multithread" => false, + "rack.multiprocess" => true, "rack.run_once" => false, "rack.url_scheme" => "http", diff --git a/lib/unicorn/semaphore.rb b/lib/unicorn/semaphore.rb deleted file mode 100644 index 1c0b87c..0000000 --- a/lib/unicorn/semaphore.rb +++ /dev/null @@ -1,46 +0,0 @@ -class Semaphore - def initialize(resource_count = 0) - @available_resource_count = resource_count - @mutex = Mutex.new - @waiting_threads = [] - end - - def wait - make_thread_wait unless resource_is_available - end - - def signal - schedule_waiting_thread if thread_is_waiting - end - - def synchronize - self.wait - yield - ensure - self.signal - end - - private - - def resource_is_available - @mutex.synchronize do - return (@available_resource_count -= 1) >= 0 - end - end - - def make_thread_wait - @waiting_threads << Thread.current - Thread.stop - end - - def thread_is_waiting - @mutex.synchronize do - return (@available_resource_count += 1) <= 0 - end - end - - def schedule_waiting_thread - thread = @waiting_threads.shift - thread.wakeup if thread - end -end |