org.apache.ignite.internal.util.offheap.unsafe

## Class GridUnsafeGuard

- java.lang.Object
- - org.apache.ignite.internal.util.offheap.unsafe.GridUnsafeGuard

    public class GridUnsafeGuard
    extends Object

Guards concurrent operations on offheap memory to make sure that no thread will access already deallocated pointer. Typical usage is:

         guard.begin();

         try {
             guard.releaseLater(x);
         }
         finally {
             guard.end();
         }

while another thread can safely read the memory being deallocated:

         guard.begin();

         try {
             mem.readLong(x.getPointer());
         }
         finally {
             guard.end();
         }

### Constructor Summary

Constructors
Constructor and Description
`GridUnsafeGuard()`

### Method Summary

Methods
`void` `begin()` Begins concurrent memory operation.
`void` `end()` Ends concurrent memory operation and releases resources.
`void` `finalizeLater(Runnable finalizer)` Does finalization when it will be safe to deallocate offheap memory.
`void` `releaseLater(GridUnsafeCompoundMemory compound)` Releases memory in the future when it will be safe to do that.
`String` `toString()`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Constructor Detail

#### GridUnsafeGuard

    public GridUnsafeGuard()

### Method Detail

#### begin

    public void begin()

Begins concurrent memory operation.

#### end

    public void end()

Ends concurrent memory operation and releases resources.

#### releaseLater

    public void releaseLater(GridUnsafeCompoundMemory compound)

Releases memory in the future when it will be safe to do that. Gives no guarantees in which thread it will be executed.

Parameters:
  `compound` - Compound memory.

#### finalizeLater

    public void finalizeLater(Runnable finalizer)

Does finalization when it will be safe to deallocate offheap memory. Gives no guarantees in which thread it will be executed. Gives no guarantees about execution order of multiple passed finalizers as well.

Parameters:
  `finalizer` - Finalizer.

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`

2015 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 1.3.0-incubating
Release Date | : July 10 2015