def eventmachine_register
    @eventmachine_attached_fds = {}
    @eventmachine_timer = nil

    pollfds = self.pollfds
    if pollfds
      pollfds.each do |pollfd|
        eventmachine_add_pollfd(pollfd)
      end

      self.on_pollfd_added do |pollfd|
        eventmachine_add_pollfd(pollfd)
      end

      self.on_pollfd_removed do |pollfd|
        eventmachine_rm_pollfd(pollfd)
      end
    else
      # Libusb pollfd API is not available on this platform.
      # Use simple polling timer, instead:
      EventMachine.add_periodic_timer(0.01) do
        @eventmachine_timer = self.handle_events 0
      end
    end
  end
def eventmachine_register
    @eventmachine_attached_fds = {}
    @eventmachine_timer = nil

    pollfds = self.pollfds
    if pollfds
      pollfds.each do |pollfd|
        eventmachine_add_pollfd(pollfd)
      end

      self.on_pollfd_added do |pollfd|
        eventmachine_add_pollfd(pollfd)
      end

      self.on_pollfd_removed do |pollfd|
        eventmachine_rm_pollfd(pollfd)
      end
    else
      # Libusb pollfd API is not available on this platform.
      # Use simple polling timer, instead:
      EventMachine.add_periodic_timer(0.01) do
        @eventmachine_timer = self.handle_events 0
      end
    end
  end
Register libusb's file descriptors and timeouts to EventMachine.

 @example
   require 'libusb/eventmachine'
   context = LIBUSB::Context.new
   EventMachine.run do
     context.eventmachine_register
   end

 @see
   DevHandle#eventmachine_bulk_transfer
   DevHandle#eventmachine_control_transfer
   DevHandle#eventmachine_interrupt_transfer