class Alo7::Net::Connection::Impl
@private
Attributes
handler[R]
@private
Public Class Methods
new(klass, *args)
click to toggle source
# File lib/alo7/net/connection.rb, line 118 def initialize(klass, *args) raise ArgumentError, "must provide a subclass of #{Connection.name}" \ unless klass <= Connection @handler = klass.new(*args) @handler.impl = self end
Public Instance Methods
await(defer)
click to toggle source
(see Net.await
)
@note It keeps the pending defers internally. When unbinding, it fails
them with a ConnectionLost error.
@note It fails the defer and raise a ConnectionLost
error
intermediately between unbinding.
# File lib/alo7/net/connection.rb, line 159 def await(defer) if @unbinding err = ConnectionLost.new defer.fail err raise err else _await defer end end
connection_completed()
click to toggle source
# File lib/alo7/net/connection.rb, line 134 def connection_completed Net.fiber_block { @handler.connection_completed } end
post_init()
click to toggle source
# File lib/alo7/net/connection.rb, line 125 def post_init Net.fiber_block do @unbinding = false @defers = [] @handler.post_init end end
receive_data(data)
click to toggle source
# File lib/alo7/net/connection.rb, line 138 def receive_data(data) Net.fiber_block { @handler.receive_data data } end
unbind()
click to toggle source
# File lib/alo7/net/connection.rb, line 142 def unbind Net.fiber_block do @unbinding = true @defers.dup.each { |defer| defer.fail ConnectionLost.new } @handler.unbind @unbinding = false end end
Private Instance Methods
_await(defer)
click to toggle source
# File lib/alo7/net/connection.rb, line 171 def _await(defer) @defers.push defer begin Net.await defer ensure @defers.delete defer end end