lib/hanami/application.rb in hanami-0.7.3 vs lib/hanami/application.rb in hanami-0.8.0
- old
+ new
@@ -38,10 +38,14 @@
synchronize do
applications.add(base)
end
end
+ # @since 0.8.0
+ # @api private
+ LOCK = Mutex.new
+
# Return the routes for this application
#
# @return [Hanami::Router] a route set
#
# @since 0.1.0
@@ -120,21 +124,22 @@
def middleware
@middleware ||= configuration.middleware
end
class << self
+ # @since 0.2.0
+ # @api private
+ @@applications = Set.new
# Registry of Hanami applications in the current Ruby process
#
# @return [Set] a set of all the registered applications
#
# @since 0.2.0
# @api private
def applications
- synchronize do
- @@applications ||= Set.new
- end
+ @@applications
end
# Configure the application.
# It yields the given block in the context of the configuration
#
@@ -236,10 +241,10 @@
# Yields the given block in a critical section
#
# @since 0.2.0
# @api private
def synchronize
- Mutex.new.synchronize do
+ LOCK.synchronize do
yield
end
end
end
end