本文整理汇总了Java中io.netty.util.internal.PlatformDependent.copyMemory方法的典型用法代码示例。如果您正苦于以下问题:Java PlatformDependent.copyMemory方法的具体用法?Java PlatformDependent.copyMemory怎么用?Java PlatformDependent.copyMemory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.netty.util.internal.PlatformDependent
的用法示例。
在下文中一共展示了PlatformDependent.copyMemory方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setBytes
import io.netty.util.internal.PlatformDependent; //导入方法依赖的package包/类
public ByteBuf setBytes(int index, ByteBuffer src, int srcIndex, int length) {
if (src.isDirect()) {
checkIndex(index, length);
PlatformDependent.copyMemory(PlatformDependent.directBufferAddress(src) + srcIndex, this.memoryAddress() + index,
length);
} else {
if (srcIndex == 0 && src.capacity() == length) {
b.setBytes(index + offset, src);
} else {
ByteBuffer newBuf = src.duplicate();
newBuf.position(srcIndex);
newBuf.limit(srcIndex + length);
b.setBytes(index + offset, src);
}
}
return this;
}
示例2: ensureAvailableBlocks
import io.netty.util.internal.PlatformDependent; //导入方法依赖的package包/类
public void ensureAvailableBlocks(int count){
if(count > capacity){
final int blockWidth = this.blockWidth;
final int sizeInBytes = Numbers.nextPowerOfTwo(count * blockWidth);
final ArrowBuf oldBuf = buf;
buf = allocator.buffer(sizeInBytes);
// since blockWidth has to be a power of two and count
final long firstBlock = buf.memoryAddress() + (capacity * blockWidth);
final int maxBytes = blockWidth * count;
final long maxBlock = buf.memoryAddress() + maxBytes;
for(long l = firstBlock; l < maxBlock; l+= 8){
PlatformDependent.putLong(l, 0);
}
int remain = maxBytes % 8;
if(remain != 0){
buf.setZero(maxBytes - remain, remain);
}
PlatformDependent.copyMemory(oldBuf.memoryAddress(), buf.memoryAddress(), capacity * blockWidth);
oldBuf.release();
this.capacity = count;
}
}
示例3: ensureAvailableDataSpace
import io.netty.util.internal.PlatformDependent; //导入方法依赖的package包/类
/**
* Expand the buffer as necessary.
* @param sizeInBytes
* @return true if the buffer was expanded (meaning one needs to reread the memory address).
*/
public boolean ensureAvailableDataSpace(int sizeInBytes){
if(buf.capacity() < sizeInBytes){
int targetSize = Numbers.nextPowerOfTwo(sizeInBytes);
final ArrowBuf oldBuf = buf;
buf = allocator.buffer(targetSize);
PlatformDependent.copyMemory(oldBuf.memoryAddress(), buf.memoryAddress(), oldBuf.capacity());
oldBuf.release();
return true;
}
return false;
}
示例4: unsafeCopy1MB
import io.netty.util.internal.PlatformDependent; //导入方法依赖的package包/类
public static void unsafeCopy1MB(final long src, final long dst, int len) {
PlatformDependent.copyMemory(src, dst, len);
}