Module: Denko::Connection::FlowControl

Defined in:
lib/denko/connection/flow_control.rb

Constant Summary collapse

BOARD_BUFFER =
63
SLEEP_TIME =
0.001

Instance Method Summary collapse

Instance Method Details

#initialize(*args) ⇒ Object



7
8
9
10
11
# File 'lib/denko/connection/flow_control.rb', line 7

def initialize(*args)
  super(*args)
  reset_flow_control
  tx_resume
end

#write(message, tx_halt_after = nil) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/denko/connection/flow_control.rb', line 13

def write(message, tx_halt_after=nil)
  @write_buffer_mutex.synchronize do
    @write_buffer << message

    # Optionally halt transmission after this message.
    # See comments on Board#write_and_halt for more info.
    @tx_halt_points << @write_buffer.length if tx_halt_after
  end
end

#writing?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/denko/connection/flow_control.rb', line 23

def writing?
  @write_buffer_mutex.synchronize { !@write_buffer.empty? }
end