Interface IResource

All Known Subinterfaces:
IMemoryAwareResource, MarshObjectConvertorResource
All Known Implementing Classes:
BaseClientPeer, BlobStoreUnpinMultiplePacket, BusPacket, ByteBufferRedoLogFileStorage.ByteArrayResource, CheckXtnStatusInTmBusPackect, CommitBusPacket, CompressedMarshObjectConvertor, ConnectionResource, ConnectionResource, CPeer, EntryArrivedPacket, EntryExpiredBusPacket, EntryTakenPacket, EntryUnmatchedPacket, EntryUpdatedPacket, MarshObjectConvertor, PacketSerializer.InputStreamsResource, ReadWriteLockResource, RemoteEventBatchBusPacket, RemoteEventBusPacket, RemoveWaitingForInfoSABusPacket, Resource, RollbackBusPacket, TraceableResource, UpdateOrWriteBusPacket

public interface IResource
A resource interface required by a ResourcePool. Resource is the default implementation. IResource may be used when dealing with hierarchy constraints.

Usage: extend your resource class from Resource public class myResource extends Resource {...} or if you have hierarchy constraints, implement IResource.

Since:
6.0.2
Version:
1.0
Author:
moran
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Atomically acquires a free resource.
    void
    Cleans the resource of its contents so it can be returned to the pool.
    boolean
    An indication if this resource is currently acquired.
    boolean
    An indication if this resource originated from the pool or was allocated on the fly.
    void
    Atomically sets this resource as free; usually when returning a resource to the pool.
    void
    setAcquired(boolean acquired)
    An indication if this resource is acquired.
    void
    setFromPool(boolean fromPool)
    An indication if this resource originated from the pool or was allocated on the fly.
  • Method Details

    • isFromPool

      boolean isFromPool()
      An indication if this resource originated from the pool or was allocated on the fly. The latter, will not return to the pool.
      Returns:
      true if originated from the pool; false if allocated.
    • setFromPool

      void setFromPool(boolean fromPool)
      An indication if this resource originated from the pool or was allocated on the fly. The latter, will not return to the pool.
      Parameters:
      fromPool - true if originated from the pool; false if not part of the pool.
    • isAcquired

      boolean isAcquired()
      An indication if this resource is currently acquired. Usually a resource becomes acquired after a call to acquire(), or by use of it's status indicator setAcquired(boolean).
      Returns:
      true if resource is acquired. false if not yet acquired.
    • setAcquired

      void setAcquired(boolean acquired)
      An indication if this resource is acquired.
      Parameters:
      acquired - true if resource is acquired. false if resource is not acquired.
    • acquire

      boolean acquire()
      Atomically acquires a free resource. But, due to race conditions, it may fail.
      Returns:
      true if acquire succeeded; false otherwise (may have already been acquired by another thread).
    • release

      void release()
      Atomically sets this resource as free; usually when returning a resource to the pool.

      Before releasing the resource back into the pool, clear() is invoked.

      Throws:
      RuntimeException - if this Resource was already free.
    • clear

      void clear()
      Cleans the resource of its contents so it can be returned to the pool.

      You may use the isFromPool() indication to decide of a special action before returning a resource to the pool, or discard any actions on resources not returning to the pool.

      See Also: