gpt4 book ai didi

org.zeromq.ZMsg.destroy()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-14 21:40:49 25 4
gpt4 key购买 nike

本文整理了Java中org.zeromq.ZMsg.destroy()方法的一些代码示例,展示了ZMsg.destroy()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZMsg.destroy()方法的具体详情如下:
包路径:org.zeromq.ZMsg
类名称:ZMsg
方法名:destroy

ZMsg.destroy介绍

[英]Destructor. Explicitly destroys all ZFrames contains in the ZMsg
[中]析构函数。显式销毁ZMsg中包含的所有Zframe

代码示例

代码示例来源:origin: twosigma/beakerx

private Message readMessage(ZMQ.Socket socket) {
 ZMsg zmsg = null;
 Message message = null;
 try {
  zmsg = ZMsg.recvMsg(socket);
  ZFrame[] parts = new ZFrame[zmsg.size()];
  zmsg.toArray(parts);
  byte[] uuid = parts[MessageParts.UUID].getData();
  byte[] header = parts[MessageParts.HEADER].getData();
  byte[] parent = parts[MessageParts.PARENT].getData();
  byte[] metadata = parts[MessageParts.METADATA].getData();
  byte[] content = parts[MessageParts.CONTENT].getData();
  byte[] expectedSig = parts[MessageParts.HMAC].getData();
  verifyDelim(parts[MessageParts.DELIM]);
  verifySignatures(expectedSig, header, parent, metadata, content);
  message = new Message(parse(header, Header.class));
  if (uuid != null) {
   message.getIdentities().add(uuid);
  }
  message.setParentHeader(parse(parent, Header.class));
  message.setMetadata(parse(metadata, LinkedHashMap.class));
  message.setContent(parse(content, LinkedHashMap.class));
 } finally {
  if (zmsg != null) {
   zmsg.destroy();
  }
 }
 return message;
}

代码示例来源:origin: org.zeromq/jeromq

private static ZapRequest recvRequest(Socket handler, boolean wait)
{
  ZMsg request = ZMsg.recvMsg(handler, wait);
  if (request == null) {
    return null;
  }
  ZapRequest self = new ZapRequest(handler, request);
  //  If the version is wrong, we're linked with a bogus libzmq, so die
  assert (ZAP_VERSION.equals(self.version));
  request.destroy();
  return self;
}

代码示例来源:origin: org.zeromq/jeromq

destroy();

代码示例来源:origin: org.zeromq/jeromq

dup.destroy();
dup = cfg.duplicate();
cold |= provider.restart(dup, backend, Plug.BACK, this.args);
dup.destroy();
dup = cfg.duplicate();
cold |= provider.restart(dup, capture, Plug.CAPTURE, this.args);
dup.destroy();
cfg.destroy();

代码示例来源:origin: org.zeromq/jeromq

public ZAuth(final ZContext ctx, String actorName, Map<String, Auth> auths)
{
  assert (ctx != null); // works only for connections within the same context
  assert (actorName != null);
  assert (auths != null);
  final AuthActor actor = new AuthActor(actorName, auths);
  final ZActor zactor = new ZActor(ctx, null, actor, UUID.randomUUID().toString());
  agent = zactor.agent();
  exit = zactor.exit();
  // wait for the start of the actor
  agent.recv().destroy();
  replies = actor.createAgent(ctx);
}

代码示例来源:origin: org.zeromq/jeromq

private String recvStatus()
{
  if (!agent.sign()) {
    return EXITED;
  }
  // receive the status response
  final ZMsg msg = agent.recv();
  if (msg == null) {
    return EXITED;
  }
  String status = msg.popString();
  msg.destroy();
  return status;
}

代码示例来源:origin: org.zeromq/jeromq

/**
 * Creates a monitoring actor for the given socket.
 * @param ctx the context relative to this actor. Not null.
 * @param socket the socket to monitor for events. Not null.
 */
public ZMonitor(ZContext ctx, Socket socket)
{
  assert (ctx != null);
  assert (socket != null);
  final MonitorActor actor = new MonitorActor(socket);
  final ZActor zactor = new ZActor(ctx, actor, UUID.randomUUID().toString());
  agent = zactor.agent();
  exit = zactor.exit();
  // wait for the start of the actor
  agent.recv().destroy();
}

代码示例来源:origin: org.zeromq/jeromq

/**
 * Receives message from socket, returns ZMsg object or null if the
 * recv was interrupted. Setting the flag to ZMQ.DONTWAIT does a non-blocking recv.
 * @param   socket
 * @param   flag see ZMQ constants
 * @return
 *          ZMsg object, null if interrupted
 */
public static ZMsg recvMsg(Socket socket, int flag)
{
  if (socket == null) {
    throw new IllegalArgumentException("socket is null");
  }
  ZMsg msg = new ZMsg();
  while (true) {
    ZFrame f = ZFrame.recvFrame(socket, flag);
    if (f == null) {
      // If receive failed or was interrupted
      msg.destroy();
      msg = null;
      break;
    }
    msg.add(f);
    if (!f.hasMore()) {
      break;
    }
  }
  return msg;
}

代码示例来源:origin: fiber-space/jupyter-kernel-jsr223

zmsg.destroy();

代码示例来源:origin: org.zeromq/jeromq

protected ZAuth send(String command, String... datas)
{
  ZMsg msg = new ZMsg();
  msg.add(command);
  for (String data : datas) {
    msg.add(data);
  }
  agent.send(msg);
  msg.destroy();
  agent.recv();
  return this;
}

代码示例来源:origin: org.zeromq/jeromq

msg.destroy();
if (!rc) {
  System.out.printf("ZAuth: Command in error %s%n", command);

代码示例来源:origin: org.zeromq/jeromq

@Override
  public boolean flow(Plug splug, Socket source, Socket capture, Plug dplug, Socket destination)
  {
    boolean success;
    // we read the whole message
    ZMsg msg = ZMsg.recvMsg(source);
    if (msg == null) {
      return false;
    }
    if (capture != null) {
      //  Copy transformed message to capture socket if any message
      // TODO what if the transformer modifies or destroys the original message ?
      ZMsg cpt = transformer.transform(msg, splug, Plug.CAPTURE);
      //                boolean destroy = !msg.equals(cpt); // TODO ?? which one
      boolean destroy = msg != cpt;
      success = cpt.send(capture, destroy);
      if (!success) {
        // not successful, but we can still try to send it to the destination
      }
    }
    ZMsg dst = transformer.transform(msg, splug, dplug);
    // we send the whole transformed message
    success = dst.send(destination);
    // finished
    msg.destroy();
    return success;
  }
}

代码示例来源:origin: org.zeromq/jeromq

ZMsg cfg = ZMsg.recvMsg(pipe);
boolean rc = provider.configure(pipe, cfg, frontend, backend, capture, args);
cfg.destroy();
return rc;

代码示例来源:origin: org.projectreactor/reactor-net

@Override
  public int handle(ZLoop loop, ZMQ.PollItem item, Object arg) {
    ZMsg msg = ZMsg.recvMsg(socket);
    if (null == msg || msg.size() == 0) {
      return 0;
    }
    if (closed) {
      return -1;
    }
    String connId;
    switch (ZeroMQWorker.this.socketType) {
      case ZMQ.ROUTER:
        connId = msg.popString();
        break;
      default:
        connId = ZeroMQWorker.this.id.toString();
    }
    ZeroMQNetChannel<IN, OUT> netChannel = select(connId)
        .setConnectionId(connId)
        .setSocket(socket);
    ZFrame content;
    while (null != (content = msg.pop())) {
      netChannel.read(Buffer.wrap(content.getData()));
    }
    msg.destroy();
    return 0;
  }
};

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com