private <T, R> R callWithOffHeapLock(T value, Function<T, R> function) {
    if (isOffHeapReference(value)) {
      synchronized (offHeapLock) {
        if (!offHeapOk) {
          throw new IllegalStateException(
              "Attempt to access off heap value after the EntryEvent was released.");
        }
        return function.apply(value);
      }
    } else {
      return function.apply(value);
    }
  }
Invoke the given function with a lock if the given value is offheap.

@return the value returned from invoking the function
geode-core/src/main/java/org/apache/geode/internal/cache/EntryEventImpl.java