lib/faastruby/server/concurrency_controller.rb in faastruby-0.4.18 vs lib/faastruby/server/concurrency_controller.rb in faastruby-0.5.0
- old
+ new
@@ -1,51 +1,51 @@
-module FaaStRuby
- class ConcurrencyController
- def self.store
- @@store ||= {}
- end
- attr_accessor :params, :name, :max, :type
- def initialize(name, max: 1, type:)
- @type = type
- @name = name
- @max = max
- @running = 0
- # @mutex = Mutex.new
- self.class.store[name] = self
- puts "[ConcurrencyController] Started controller for '#{name}' with max_concurrency = #{@max}".yellow
- end
-
- def running
- # puts "[ConcurrencyController] [#{name}] Reading runners".red
- # wait
- # puts "[ConcurrencyController] [#{name}] Locking mutex".red
- # @mutex.lock
- @running
- # ensure
- # puts "[ConcurrencyController] [#{name}] Unlocking mutex".red
- # @mutex.unlock
- end
+# module FaaStRuby
+# class ConcurrencyController
+# def self.store
+# @@store ||= {}
+# end
+# attr_accessor :params, :name, :max, :type
+# def initialize(name, max: 1, type:)
+# @type = type
+# @name = name
+# @max = max
+# @running = 0
+# # @mutex = Mutex.new
+# self.class.store[name] = self
+# puts "(ConcurrencyController) Started controller for '#{name}' with max_concurrency = #{@max}".yellow
+# end
- def decr(amount = 1)
- incr(0 - amount)
- end
-
- def incr(amount = 1)
- # puts "[ConcurrencyController] [#{name}] Incr #{amount}".red
- # wait
- # puts "[ConcurrencyController] [#{name}] Locking mutex".red
- # @mutex.lock
- current = @running + amount
- return nil if max < current
- @running += amount
- # ensure
- # puts "[ConcurrencyController] [#{name}] Unlocking mutex".red
- # @mutex.unlock
- end
-
- # def wait
- # puts "[ConcurrencyController] [#{name}] Waiting for mutex lock to release".red
- # while @mutex.locked? do;end
- # puts "[ConcurrencyController] [#{name}] Mutex released".red
- # end
- end
-end
+# def running
+# # puts "[ConcurrencyController] [#{name}] Reading runners".red
+# # wait
+# # puts "[ConcurrencyController] [#{name}] Locking mutex".red
+# # @mutex.lock
+# @running
+# # ensure
+# # puts "[ConcurrencyController] [#{name}] Unlocking mutex".red
+# # @mutex.unlock
+# end
+
+# def decr(amount = 1)
+# incr(0 - amount)
+# end
+
+# def incr(amount = 1)
+# # puts "[ConcurrencyController] [#{name}] Incr #{amount}".red
+# # wait
+# # puts "[ConcurrencyController] [#{name}] Locking mutex".red
+# # @mutex.lock
+# current = @running + amount
+# return nil if max < current
+# @running += amount
+# # ensure
+# # puts "[ConcurrencyController] [#{name}] Unlocking mutex".red
+# # @mutex.unlock
+# end
+
+# # def wait
+# # puts "[ConcurrencyController] [#{name}] Waiting for mutex lock to release".red
+# # while @mutex.locked? do;end
+# # puts "[ConcurrencyController] [#{name}] Mutex released".red
+# # end
+# end
+# end