Sha256: c7aed5efd2f5a6621e5a7ae5799350b7e546296ff7227c0f334cf8cdae31e8c1

Contents?: true

Size: 689 Bytes

Versions: 3

Compression:

Stored size: 689 Bytes

Contents

require 'thread_safe'
require 'set'

module Libuv
    module Listener


        private


        CALLBACKS = ThreadSafe::Cache.new


        def callbacks
            @callbacks ||= Set.new
        end

        def callback(name)
            const_name = "#{name}_#{object_id}".to_sym
            unless CALLBACKS[const_name]
                callbacks << const_name
                CALLBACKS[const_name] = method(name)
            end
            CALLBACKS[const_name]
        end

        def clear_callbacks
            callbacks.each do |name|
                CALLBACKS.delete(name)
            end
            callbacks.clear
        end
    end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
libuv-0.11.22 lib/libuv/mixins/listener.rb
libuv-0.11.4 lib/libuv/mixins/listener.rb
libuv-0.10.0 lib/libuv/listener.rb