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.



102
103
104
105
106
107
# File 'lib/infra/ospf_io.rb', line 102

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.



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

def thread
  @thread
end

Instance Method Details

#startObject



117
118
119
120
121
122
123
124
125
126
127
128
129
# File 'lib/infra/ospf_io.rb', line 117

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

#stopObject



111
112
113
114
115
# File 'lib/infra/ospf_io.rb', line 111

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