Sha256: 1c461e0eee3958cd91d6ddcf8615d18e32c8d73437009648a865c94f34faff12

Contents?: true

Size: 648 Bytes

Versions: 11

Compression:

Stored size: 648 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}"
            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

11 entries across 11 versions & 1 rubygems

Version Path
libuv-1.2.0 lib/libuv/mixins/listener.rb
libuv-1.1.3 lib/libuv/mixins/listener.rb
libuv-1.1.2 lib/libuv/mixins/listener.rb
libuv-1.1.1 lib/libuv/mixins/listener.rb
libuv-1.1.0 lib/libuv/mixins/listener.rb
libuv-1.0.3 lib/libuv/mixins/listener.rb
libuv-1.0.2 lib/libuv/mixins/listener.rb
libuv-1.0.0 lib/libuv/mixins/listener.rb
libuv-0.12.4 lib/libuv/mixins/listener.rb
libuv-0.12.3 lib/libuv/mixins/listener.rb
libuv-0.12.2 lib/libuv/mixins/listener.rb