Class: Cosmos::Bridge

Inherits:
Object show all
Defined in:
lib/cosmos/bridge/bridge.rb

Instance Method Summary collapse

Constructor Details

#initialize(filename) ⇒ Bridge

Returns a new instance of Bridge.



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/cosmos/bridge/bridge.rb', line 27

def initialize(filename)
  @config = BridgeConfig.new(filename)
  @threads = []

  # Start Interface Threads
  @config.interfaces.each do |interface_name, interface|
    @threads << BridgeInterfaceThread.new(interface)
    @threads[-1].start
  end

  # Start Router Threads
  @config.routers.each do |router_name, router|
    @threads << BridgeRouterThread.new(router)
    @threads[-1].start
  end

  at_exit() do
    shutdown()
  end
end

Instance Method Details

#shutdownObject



48
49
50
51
52
# File 'lib/cosmos/bridge/bridge.rb', line 48

def shutdown
  @threads.each do |thread|
    thread.stop
  end
end