public this repo is viewable by everyone
Description: Merb Core: All you need. None you don't.
Homepage: http://www.merbivore.com
Clone URL: git://github.com/wycats/merb-core.git
add mutex around compiled statement generation in the router so reloading 
doesn't step
on itself when reloading the router.
ezmobius (author)
about 1 month ago
commit  5fb660a31565e28f941d23c8e7d722f8c8d848ad
tree    2b115cebd7cb6cb21456c33803554547a0d99cb2
parent  6867c0b8c4f8a985b7e75c571be9aea9e077861e
...
11
12
13
 
14
15
16
...
52
53
54
55
56
57
58
59
60
61
 
 
 
 
 
 
 
 
 
62
63
64
...
11
12
13
14
15
16
17
...
53
54
55
 
 
 
 
 
 
 
56
57
58
59
60
61
62
63
64
65
66
67
0
@@ -11,6 +11,7 @@ module Merb
0
     
0
     @@named_routes = {}
0
     @@routes = []
0
+ @@compiler_mutex = Mutex.new
0
     cattr_accessor :routes, :named_routes
0
     
0
     class << self
0
@@ -52,13 +53,15 @@ module Merb
0
       # ==== Returns
0
       # String:: A routing lambda statement generated from the routes.
0
       def compiled_statement
0
- @@compiled_statement = "def match(request)\n"
0
- @@compiled_statement << " params = request.params\n"
0
- @@compiled_statement << " cached_path = request.path\n cached_method = request.method.to_s\n "
0
- @@routes.each_with_index { |route, i| @@compiled_statement << route.compile(i == 0) }
0
- @@compiled_statement << " else\n [nil, {}]\n"
0
- @@compiled_statement << " end\n"
0
- @@compiled_statement << "end"
0
+ @@compiler_mutex.synchronize do
0
+ @@compiled_statement = "def match(request)\n"
0
+ @@compiled_statement << " params = request.params\n"
0
+ @@compiled_statement << " cached_path = request.path\n cached_method = request.method.to_s\n "
0
+ @@routes.each_with_index { |route, i| @@compiled_statement << route.compile(i == 0) }
0
+ @@compiled_statement << " else\n [nil, {}]\n"
0
+ @@compiled_statement << " end\n"
0
+ @@compiled_statement << "end"
0
+ end
0
       end
0
 
0
       # Defines the match function for this class based on the
...
1
2
3
 
4
5
6
...
1
2
 
3
4
5
6
0
@@ -1,6 +1,6 @@
0
 require 'benchmark'
0
 
0
-TIMES = (ARGV[0] || 100_000).to_i
0
+TIMES = (ARGV[0] || 10_000).to_i
0
 
0
 Benchmark.bmbm do |x|
0
   x.report("instance_methods.include? == true") do

Comments

    No one has commented yet.