Class: Bran::LibUV::Reactor::Collections::Read

Inherits:
AbstractSister show all
Defined in:
lib/bran/libuv/reactor/collections.rb

Instance Attribute Summary

Attributes inherited from AbstractSister

#item_pool, #sister

Instance Method Summary collapse

Methods inherited from AbstractSister

#bond_with, #drop_item, #make_item

Methods inherited from Abstract

#drop_item, #invoke_by_addr, #invoke_by_ident, #invoke_handler, #item_by_ident, #make_item, #pop, #push

Constructor Details

#initializeRead

Returns a new instance of Read.



135
136
137
138
139
# File 'lib/bran/libuv/reactor/collections.rb', line 135

def initialize(*)
  super
  @callback    = FFI.uv_poll_cb(&@reactor.method(:_read_callback))
  @rw_callback = FFI.uv_poll_cb(&@reactor.method(:_rw_callback))
end

Instance Method Details

#concrete_alloc_itemObject



141
142
143
# File 'lib/bran/libuv/reactor/collections.rb', line 141

def concrete_alloc_item
  @item_pool.pop || FFI.uv_poll_alloc
end

#concrete_release_item(item) ⇒ Object



145
146
147
# File 'lib/bran/libuv/reactor/collections.rb', line 145

def concrete_release_item(item)
  @item_pool << item
end

#concrete_sister_share_item(ident, item) ⇒ Object



162
163
164
165
166
# File 'lib/bran/libuv/reactor/collections.rb', line 162

def concrete_sister_share_item(ident, item)
  Util.error_check "starting the poll readable + writable item",
    FFI.uv_poll_start(item,
      FFI::UV_READABLE | FFI::UV_WRITABLE, @rw_callback)
end

#concrete_sister_unshare_item(ident, item) ⇒ Object



168
169
170
171
# File 'lib/bran/libuv/reactor/collections.rb', line 168

def concrete_sister_unshare_item(ident, item)
  Util.error_check "restarting the poll readable item",
    FFI.uv_poll_start(item, FFI::UV_READABLE, @callback)
end

#concrete_start_item(ident, item) ⇒ Object



149
150
151
152
153
154
155
# File 'lib/bran/libuv/reactor/collections.rb', line 149

def concrete_start_item(ident, item)
  Util.error_check "creating the poll readable item",
    FFI.uv_poll_init(@reactor.ptr, item, ident)
  
  Util.error_check "starting the poll readable item",
    FFI.uv_poll_start(item, FFI::UV_READABLE, @callback)
end

#concrete_stop_item(ident, item) ⇒ Object



157
158
159
160
# File 'lib/bran/libuv/reactor/collections.rb', line 157

def concrete_stop_item(ident, item)
  Util.error_check "stopping the poll readable item",
    FFI.uv_poll_stop(item)
end