Skip to content

Instantly share code, notes, and snippets.

@csmr
Created October 20, 2018 21:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save csmr/c114ae746f5ba531830ae553fe184544 to your computer and use it in GitHub Desktop.
Save csmr/c114ae746f5ba531830ae553fe184544 to your computer and use it in GitHub Desktop.
# read_pipes
def read_pipes
msg = nil
msg = read_line_nonblocking( @pipe_from_eng )
if msg != nil
p_dbg "got msg: #{msg}", self
end
if msg == "2"
@pipe_to_ui.puts "Engine told me: 2"
@pipe_to_ui.flush
end
msg = nil
msg = read_line_nonblocking( @pipe_from_ui )
if msg != nil
p_dbg "got msg: #{msg}", self
@msg_stack.push msg
end
end
@baweaver
Copy link

# read_pipes
def read_pipes
  Qo.case(read_line_nonblocking(@pipe_from_eng)) { |m|
    m.when(Qo.not(nil), '2') {
      p_dbg("got msg: #{msg}", self)
      @pipe_to_ui.puts "Engine told me: 2"
      @pipe_to_ui.flush
    }
    
    m.when(Qo.not(nil)) {
      p_dbg("got msg: #{msg}", self)
    }
  }

  Qo.case(read_line_nonblocking(@pipe_from_ui)) { |m|
    m.when(Qo.not(nil)) { |message|
      p_dbg "got msg: #{msg}", self                                                                                                                  
      @msg_stack.push msg 
    }
  }
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment