Class: OSPFv2::OutputQ

Inherits:
Queue
  • Object
show all
Includes:
Observable
Defined in:
lib/infra/ospf_io.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sock, *obs) ⇒ OutputQ

Returns a new instance of OutputQ.



107
108
109
110
111
112
# File 'lib/infra/ospf_io.rb', line 107

def initialize(sock, *obs)
  super()
  @sock= sock
  obs.each { |o| self.add_observer(o) }
  @continue = true
end

Instance Attribute Details

#threadObject (readonly)

Returns the value of attribute thread.



114
115
116
# File 'lib/infra/ospf_io.rb', line 114

def thread
  @thread
end

Instance Method Details

#startObject



122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/infra/ospf_io.rb', line 122

def start
  @thread = Thread.new(@sock) do |s|
    Thread.current['name'] = self.class.to_s
    begin
      while @continue
        el = deq
        @sock.send(*el)
        Thread.pass
      end
    rescue => e
      p e
    end
  end
end

#stopObject



116
117
118
119
120
# File 'lib/infra/ospf_io.rb', line 116

def stop
  @thread.exit
  @thread.join
rescue
end