public
Description: New and ultra-turbo-crazy-fast backend for Thin
Homepage: http://code.macournoyer.com/thin/
Clone URL: git://github.com/macournoyer/thin-turbo.git
Search Repo:
Monkey patch Thin Rails adapter to add a mutex
macournoyer (author)
Wed Apr 30 19:57:31 -0700 2008
commit  0f7afa9c06008d9467a62977661efe8ceea74c1b
tree    33f5e9b175d0900701eb4840bd63b6dad6d3e355
parent  9df329be7c5ba0f634f063086f12f4b7859454a6
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
0
@@ -1 +1,32 @@
0
+require 'rack/adapter/rails'
0
+
0
+# Monkey patch Thin Rails adapter to add a mutex
0
+module Rack
0
+ module Adapter
0
+ class Rails
0
+ def initialize_with_mutex(*args)
0
+ @mutex = Mutex.new
0
+ initialize_without_mutex(*args)
0
+
0
+ puts "using threaded rails"
0
+ end
0
+ alias_method :initialize_without_mutex, :initialize
0
+ alias_method :initialize, :initialize_with_mutex
0
+
0
+ def serve_rails(env)
0
+ request = Request.new(env)
0
+ response = Response.new
0
+
0
+ session_options = ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS
0
+ cgi = CGIWrapper.new(request, response)
0
+
0
+ @mutex.synchronize do
0
+ Dispatcher.dispatch(cgi, session_options, response)
0
+ end
0
+
0
+ response.finish
0
+ end
0
+ end
0
+ end
0
+end
...
4
5
6
 
...
4
5
6
7
0
@@ -4,4 +4,5 @@
0
 
0
 require File.dirname(__FILE__) + "/../ext/thin_backend/thin_backend"
0
 require File.dirname(__FILE__) + "/thin/backends/turbo"
0
+require File.dirname(__FILE__) + "/rack/adapter/threaded_rails"

Comments

    No one has commented yet.