Interface Owned<T>

  • Type Parameters:
    T - The concrete type of Resource that is owned.

    public interface Owned<T>
    This interface encapsulates the ownership of a Resource, and exposes a method that may be used to transfer this ownership to the specified recipient thread.
    • Method Detail

      • transferOwnership

        T transferOwnership​(Drop<T> drop)
        Transfer the ownership of the resource, to the calling thread. The resource instance is invalidated but without disposing of its internal state. Then a new resource instance with the given owner is produced in its stead.

        This method is called by Send implementations. These implementations will ensure that the transfer of ownership (the calling of this method) happens-before the new owner begins accessing the new object. This ensures that the new resource instance is safely published to the new owners.

        Parameters:
        drop - The drop object that knows how to dispose of the state represented by this Resource.
        Returns:
        A new resource instance that is exactly the same as this resource.