Class: Hakuban::ObjectDescriptorEventQueue

Inherits:
Object
  • Object
show all
Defined in:
lib/hakuban/event-queue.rb

Instance Method Summary collapse

Constructor Details

#initialize(contract) ⇒ ObjectDescriptorEventQueue



49
50
51
52
53
54
55
56
57
# File 'lib/hakuban/event-queue.rb', line 49

def initialize(contract)
  @contract = contract
  @queue = Queue.new
  @ffi_callback = proc { |descriptor, action|
    @queue << Hakuban::Event.new(action: action, descriptor: descriptor)
  }
  @ffi_events = @contract.new_callback_event_queue
  @ffi_events.callback_register(&@ffi_callback)
end

Instance Method Details

#closeObject



71
72
73
# File 'lib/hakuban/event-queue.rb', line 71

def close
  @queue.close
end

#next_changeObject



66
67
68
# File 'lib/hakuban/event-queue.rb', line 66

def next_change
  @queue.pop
end

#next_eventObject



65
# File 'lib/hakuban/event-queue.rb', line 65

def next_event; next_change; end