Example #1
0
  //  Writes a message to the underlying pipe. Returns false if the
  //  message cannot be written because high watermark was reached.
  public boolean write(Msg msg_) {
    if (!check_write()) return false;

    boolean more = msg_.hasMore();
    outpipe.write(msg_, more);

    if (!more) msgs_written++;

    return true;
  }
Example #2
0
  //  Reads a message to the underlying pipe.
  public Msg read() {
    if (!in_active || (state != State.ACTIVE && state != State.PENDING)) return null;

    Msg msg_ = inpipe.read();

    if (msg_ == null) {
      in_active = false;
      return null;
    }

    //  If delimiter was read, start termination process of the pipe.
    if (msg_.isDelimiter()) {
      delimit();
      return null;
    }

    if (!msg_.hasMore()) msgs_read++;

    if (lwm > 0 && msgs_read % lwm == 0) send_activate_write(peer, msgs_read);

    return msg_;
  }