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