Sha256: 5c3cce39286c767247a25200b5b9650f81ee3ef3a55ce1f3ee47ad02b311f00b

Contents?: true

Size: 1.49 KB

Versions: 30

Compression:

Stored size: 1.49 KB

Contents

# 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

#     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

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
faastruby-0.5.30 lib/faastruby/server/concurrency_controller.rb
faastruby-0.5.29 lib/faastruby/server/concurrency_controller.rb
faastruby-0.5.28 lib/faastruby/server/concurrency_controller.rb
faastruby-0.5.27 lib/faastruby/server/concurrency_controller.rb
faastruby-0.5.26 lib/faastruby/server/concurrency_controller.rb
faastruby-0.5.25 lib/faastruby/server/concurrency_controller.rb
faastruby-0.5.24 lib/faastruby/server/concurrency_controller.rb
faastruby-0.5.23 lib/faastruby/server/concurrency_controller.rb
faastruby-0.5.22 lib/faastruby/server/concurrency_controller.rb
faastruby-0.5.21 lib/faastruby/server/concurrency_controller.rb
faastruby-0.5.20 lib/faastruby/server/concurrency_controller.rb
faastruby-0.5.19 lib/faastruby/server/concurrency_controller.rb
faastruby-0.5.18 lib/faastruby/server/concurrency_controller.rb
faastruby-0.5.17 lib/faastruby/server/concurrency_controller.rb
faastruby-0.5.16 lib/faastruby/server/concurrency_controller.rb
faastruby-0.5.15 lib/faastruby/server/concurrency_controller.rb
faastruby-0.5.14 lib/faastruby/server/concurrency_controller.rb
faastruby-0.5.13 lib/faastruby/server/concurrency_controller.rb
faastruby-0.5.12 lib/faastruby/server/concurrency_controller.rb
faastruby-0.5.11 lib/faastruby/server/concurrency_controller.rb