Method: LIBUSB::Context.free_context

Defined in:
lib/libusb/context.rb

.free_context(id) ⇒ Object



136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# File 'lib/libusb/context.rb', line 136

def @ctx.free_context(id)
  @free_context = true
  if @refs == 0
    # puts "final libusb_exit #{to_i} #{id} #{caller[0]}"
    if id # Is Context is about to be garbage collected?
      # In GC mode there's no way to call the registered collbacks, since they are GC'ed as well.
      # So disable callbacks now.
      if Call.respond_to?(:libusb_set_log_cb)
        Call.libusb_set_log_cb(self, nil, LOG_CB_CONTEXT)
      end
      Call.libusb_set_pollfd_notifiers(self, nil, nil, nil)
    end
    Call.libusb_exit(self)
    @refs = nil
  end
end