Search in sources :

Example 1 with GridCacheAtomicReferenceImpl

use of org.apache.ignite.internal.processors.datastructures.GridCacheAtomicReferenceImpl in project ignite by apache.

the class PlatformAtomicReference method createInstance.

/**
     * Creates an instance or returns null.
     *
     * @param ctx Context.
     * @param name Name.
     * @param memPtr Pointer to a stream with initial value. 0 for default value.
     * @param create Create flag.
     * @return Instance of a PlatformAtomicReference, or null when Ignite reference with specific name is null.
     */
public static PlatformAtomicReference createInstance(PlatformContext ctx, String name, long memPtr, boolean create) {
    assert ctx != null;
    assert name != null;
    Object initVal = null;
    if (memPtr != 0) {
        try (PlatformMemory mem = ctx.memory().get(memPtr)) {
            initVal = ctx.reader(mem).readObjectDetached();
        }
    }
    GridCacheAtomicReferenceImpl atomicRef = (GridCacheAtomicReferenceImpl) ctx.kernalContext().grid().atomicReference(name, initVal, create);
    if (atomicRef == null)
        return null;
    return new PlatformAtomicReference(ctx, atomicRef);
}
Also used : GridCacheAtomicReferenceImpl(org.apache.ignite.internal.processors.datastructures.GridCacheAtomicReferenceImpl) PlatformMemory(org.apache.ignite.internal.processors.platform.memory.PlatformMemory)

Aggregations

GridCacheAtomicReferenceImpl (org.apache.ignite.internal.processors.datastructures.GridCacheAtomicReferenceImpl)1 PlatformMemory (org.apache.ignite.internal.processors.platform.memory.PlatformMemory)1