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


Java GridUnsafe.compareAndSwapLong方法代码示例

本文整理汇总了Java中org.apache.ignite.internal.util.GridUnsafe.compareAndSwapLong方法的典型用法代码示例。如果您正苦于以下问题:Java GridUnsafe.compareAndSwapLong方法的具体用法?Java GridUnsafe.compareAndSwapLong怎么用?Java GridUnsafe.compareAndSwapLong使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.ignite.internal.util.GridUnsafe的用法示例。


在下文中一共展示了GridUnsafe.compareAndSwapLong方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: borrowFreePage

import org.apache.ignite.internal.util.GridUnsafe; //导入方法依赖的package包/类
/**
 * @return Relative pointer to a free page that was borrowed from the allocated pool.
 */
private long borrowFreePage() {
    while (true) {
        long freePageRelPtrMasked = GridUnsafe.getLong(freePageListPtr);

        long freePageRelPtr = freePageRelPtrMasked & ADDRESS_MASK;

        if (freePageRelPtr != INVALID_REL_PTR) {
            long freePageAbsPtr = absolute(freePageRelPtr);

            long nextFreePageRelPtr = GridUnsafe.getLong(freePageAbsPtr) & ADDRESS_MASK;

            long cnt = ((freePageRelPtrMasked & COUNTER_MASK) + COUNTER_INC) & COUNTER_MASK;

            if (GridUnsafe.compareAndSwapLong(null, freePageListPtr, freePageRelPtrMasked, nextFreePageRelPtr | cnt)) {
                GridUnsafe.putLong(freePageAbsPtr, PAGE_MARKER);

                return freePageRelPtr;
            }
        }
        else
            return INVALID_REL_PTR;
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:27,代码来源:PageMemoryImpl.java

示例2: updateAtomicLong

import org.apache.ignite.internal.util.GridUnsafe; //导入方法依赖的package包/类
/**
 * @param ptr Pointer to update.
 * @param delta Delta.
 */
private static long updateAtomicLong(long ptr, long delta) {
    while (true) {
        long old = GridUnsafe.getLong(ptr);

        long updated = old + delta;

        if (GridUnsafe.compareAndSwapLong(null, ptr, old, updated))
            return updated;
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:15,代码来源:PageMemoryImpl.java

示例3: casLong

import org.apache.ignite.internal.util.GridUnsafe; //导入方法依赖的package包/类
/**
 * @param ptr Pointer.
 * @param exp Expected.
 * @param v New value.
 * @return {@code true} If operation succeeded.
 */
public boolean casLong(long ptr, long exp, long v) {
    return GridUnsafe.compareAndSwapLong(null, ptr, exp, v);
}
 
开发者ID:apache,项目名称:ignite,代码行数:10,代码来源:GridUnsafeMemory.java


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