当前位置: 首页>>代码示例>>Java>>正文


Java ReferenceCounted类代码示例

本文整理汇总了Java中io.atomix.catalyst.util.reference.ReferenceCounted的典型用法代码示例。如果您正苦于以下问题:Java ReferenceCounted类的具体用法?Java ReferenceCounted怎么用?Java ReferenceCounted使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ReferenceCounted类属于io.atomix.catalyst.util.reference包,在下文中一共展示了ReferenceCounted类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleRequestSuccess

import io.atomix.catalyst.util.reference.ReferenceCounted; //导入依赖的package包/类
/**
 * Handles a request response.
 */
private void handleRequestSuccess(long requestId, Object response, ThreadContext context) {
  ByteBuf buffer = channel.alloc().buffer(10)
    .writeByte(RESPONSE)
    .writeLong(requestId)
    .writeByte(SUCCESS);

  try {
    writeResponse(buffer, response, context);
  } catch (SerializationException e) {
    handleRequestFailure(requestId, e, context);
    return;
  }

  channel.writeAndFlush(buffer, channel.voidPromise());

  if (response instanceof ReferenceCounted) {
    ((ReferenceCounted) response).release();
  }
}
 
开发者ID:atomix,项目名称:catalyst,代码行数:23,代码来源:NettyConnection.java

示例2: sendRequest

import io.atomix.catalyst.util.reference.ReferenceCounted; //导入依赖的package包/类
/**
 * Sends a request.
 */
private void sendRequest(Object request, ContextualFuture future) {
  if (open && connection.open) {
    long requestId = ++this.requestId;
    futures.put(requestId, future);
    connection.handleRequest(requestId, request);
  } else {
    future.context.executor().execute(() -> future.completeExceptionally(new ConnectException("connection closed")));
  }

  if (request instanceof ReferenceCounted) {
    ((ReferenceCounted<?>) request).release();
  }
}
 
开发者ID:atomix,项目名称:catalyst,代码行数:17,代码来源:LocalConnection.java

示例3: writeRequest

import io.atomix.catalyst.util.reference.ReferenceCounted; //导入依赖的package包/类
/**
 * Writes a request to the given buffer.
 */
private ByteBuf writeRequest(ByteBuf buffer, Object request, ThreadContext context) {
  context.serializer().writeObject(request, OUTPUT.get().setByteBuf(buffer));
  if (request instanceof ReferenceCounted) {
    ((ReferenceCounted) request).release();
  }
  return buffer;
}
 
开发者ID:atomix,项目名称:catalyst,代码行数:11,代码来源:NettyConnection.java

示例4: read

import io.atomix.catalyst.util.reference.ReferenceCounted; //导入依赖的package包/类
@Override
public T read(Class<T> type, BufferInput buffer, Serializer serializer) {
  if (ReferenceCounted.class.isAssignableFrom(type)) {
    return readReference(type, buffer, serializer);
  } else {
    return readObject(type, buffer, serializer);
  }
}
 
开发者ID:atomix,项目名称:catalyst,代码行数:9,代码来源:CatalystSerializableSerializer.java

示例5: createFactory

import io.atomix.catalyst.util.reference.ReferenceCounted; //导入依赖的package包/类
/**
 * Dynamically created a reference factory for a pooled type.
 */
private ReferenceFactory<?> createFactory(final Constructor<?> constructor) {
  return manager -> {
    try {
      return (ReferenceCounted<?>) constructor.newInstance(manager);
    } catch (InstantiationException | IllegalAccessException | InvocationTargetException e) {
      throw new SerializationException("failed to instantiate reference", e);
    }
  };
}
 
开发者ID:atomix,项目名称:catalyst,代码行数:13,代码来源:CatalystSerializableSerializer.java


注:本文中的io.atomix.catalyst.util.reference.ReferenceCounted类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。