Class FileInfoBackingCache.CachedFileInfo

All Implemented Interfaces:
Recyclable
Enclosing class:
FileInfoBackingCache

class FileInfoBackingCache.CachedFileInfo extends FileInfo
  • Field Details

    • ledgerId

      final long ledgerId
    • refCount

      final AtomicInteger refCount
  • Constructor Details

  • Method Details

    • tryRetain

      boolean tryRetain()
      Attempt to retain the file info. When a client obtains a fileinfo from a container object, but that container object may release the fileinfo before the client has a chance to call retain. In this case, the file info could be released and the destroyed before we ever get a chance to use it.

      tryRetain avoids this problem, by doing a compare-and-swap on the reference count. If the refCount is negative, it means that the fileinfo is being cleaned up, and this fileinfo object should not be used. This works in tandem with #markDead, which will only set the refCount to negative if noone currently has it retained (i.e. the refCount is 0).

      Returns:
      true if we managed to increment the refcount, false otherwise
    • getRefCount

      int getRefCount()
    • release

      void release()
    • toString

      public String toString()
      Overrides:
      toString in class Object