Class: Pwrake::CommChannel

Inherits:
Object
  • Object
show all
Defined in:
lib/pwrake/branch/communicator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host, id, queue, writer, ios = []) ⇒ CommChannel

Returns a new instance of CommChannel.



5
6
7
8
9
10
11
# File 'lib/pwrake/branch/communicator.rb', line 5

def initialize(host,id,queue,writer,ios=[])
  @host = host
  @id = id
  @queue = queue
  @writer = writer
  @ios = ios
end

Instance Attribute Details

#hostObject (readonly)

Returns the value of attribute host.



13
14
15
# File 'lib/pwrake/branch/communicator.rb', line 13

def host
  @host
end

#idObject (readonly)

Returns the value of attribute id.



13
14
15
# File 'lib/pwrake/branch/communicator.rb', line 13

def id
  @id
end

Instance Method Details

#get_lineObject



24
25
26
# File 'lib/pwrake/branch/communicator.rb', line 24

def get_line
  @queue.deq
end

#haltObject



28
29
30
31
# File 'lib/pwrake/branch/communicator.rb', line 28

def halt
  @queue.halt
  @writer.halt
end

#put_line(s) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/pwrake/branch/communicator.rb', line 15

def put_line(s)
  if $cause_fault
    $cause_fault = nil
    Log.warn("closing writer io caller=\n#{caller.join("\n")}")
    @ios.each{|io| io.close}
  end
  @writer.put_line(s,@id)
end