Class: Hakuban::TagExposeContract

Inherits:
ExposeContract show all
Includes:
Stream
Defined in:
lib/hakuban/contract.rb

Instance Attribute Summary

Attributes inherited from Contract

#descriptor

Instance Method Summary collapse

Methods included from Stream

#each, #for_each, #for_each_concurrent, #for_each_in_thread, #for_each_till_next

Methods inherited from Contract

#inspect

Methods inherited from FFIObject

#do_and_drop_or_return, #drop, #dropped?, from_ffi_pointer, generate_finalizer, #initialize_copy, #inspect, #with_pointer, with_pointers

Constructor Details

#initialize(exchange, descriptor, capacity, &block) ⇒ TagExposeContract

Returns a new instance of TagExposeContract.



121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/hakuban/contract.rb', line 121

def initialize(exchange, descriptor, capacity, &block)
  super()
  @exchange, @descriptor = exchange, descriptor
  Thread.handle_interrupt(Object => :never) {
    @exchange.with_pointer { |exchange_pointer|
      @descriptor.with_pointer { |descriptor_pointer|
        initialize_pointer(FFI::hakuban_tag_expose_contract_new(exchange_pointer, descriptor_pointer, capacity),:hakuban_tag_expose_contract_drop,nil)
      }
    }
    do_and_drop_or_return(&block)
  }
end

Instance Method Details

#next(&block) ⇒ Object



138
139
140
141
142
143
144
# File 'lib/hakuban/contract.rb', line 138

def next(&block)
  process_item(
    lambda { |pointer| FFI::hakuban_tag_expose_contract_next(pointer) },
    lambda { |pointer| FFIObject::from_ffi_pointer(ObjectStateSink, pointer) },
    &block        
  )
end