Interface NDResource

  • All Superinterfaces:
    java.lang.AutoCloseable
    All Known Subinterfaces:
    LazyNDArray, NDArray, SparseNDArray
    All Known Implementing Classes:
    NDArrayAdapter, NDList

    public interface NDResource
    extends java.lang.AutoCloseable
    An object which is managed by an NDManager and tracks the manager it is attached to.
    • Method Detail

      • getResourceNDArrays

        java.util.List<NDArray> getResourceNDArrays()
        Returns the NDArray or NDArrays contained within this resource.
        Returns:
        the NDArray or NDArrays contained within this resource
      • returnResource

        default void returnResource​(NDManager manager)
        Attaches this NDResource to the specified NDManager from which it was previously detached and temp-attached to the current manager of this resource. This is functionally equivalent to the attach method, however the cap-state disregarded when adding the resource back to the original manager.
        Parameters:
        manager - the NDManager to be attached to
      • tempAttach

        void tempAttach​(NDManager manager)
        Temporarily attaches this NDResource to the specified NDManager.

        Attached resource will be returned to the original manager when the NDManager is closed.

        Parameters:
        manager - the NDManager to be attached to
      • detach

        void detach()
        Detaches the NDResource from current NDManager's lifecycle.

        This becomes un-managed and it is the user's responsibility to close this. Failure to close the resource might cause your machine to run out of native memory.

        See Also:
        NDManager
      • close

        void close()
        Specified by:
        close in interface java.lang.AutoCloseable