Sha256: b8846cb4c885d9f971cda858f1e33f29f85f6077d4c30970abc4918e517b23a4
Contents?: true
Size: 621 Bytes
Versions: 2
Compression:
Stored size: 621 Bytes
Contents
module Yrpc module Interceptors class Registry def initialize @interceptors ||= [] end def use(interceptor_class, options = {}) interceptors_mutex do @interceptors << { klass: interceptor_class, options: options } end end #ruby 互斥锁,防止线程对资源进行竞争,导致资源不同步 def interceptors_mutex(&block) @interceptors_mutex ||= begin require 'monitor' Monitor.new end @interceptors_mutex.synchronize(&block) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ampedxx-yrpc-0.1.6 | lib/yrpc/interceptors/register.rb |
ampedxx-yrpc-0.1.4 | lib/yrpc/interceptors/register.rb |