Module io.netty5.transport
Package io.netty5.channel
Class BufferAddressedEnvelope<A extends SocketAddress,T extends BufferAddressedEnvelope<A,T>>
- java.lang.Object
-
- io.netty5.channel.DefaultAddressedEnvelope<Buffer,A>
-
- io.netty5.channel.BufferAddressedEnvelope<A,T>
-
- Type Parameters:
A- The type of socket address used for recipient and sender.T- The concrete sub-type of this class, used for implementingsend().
- All Implemented Interfaces:
AddressedEnvelope<Buffer,A>,Resource<T>,AutoCloseable
- Direct Known Subclasses:
DatagramPacket,DefaultBufferAddressedEnvelope
public abstract class BufferAddressedEnvelope<A extends SocketAddress,T extends BufferAddressedEnvelope<A,T>> extends DefaultAddressedEnvelope<Buffer,A> implements Resource<T>
Base class for addressed envelopes that haveBufferinstances as messages.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedBufferAddressedEnvelope(Buffer message, A recipient)protectedBufferAddressedEnvelope(Buffer message, A recipient, A sender)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidclose()Close the resource, making it inaccessible.booleanisAccessible()Check if this object is accessible.abstract Treplace(Buffer content)Create a new addressed envelope instance, that has the same recipient and sender as this one, but the given content.Send<T>send()Send this object instance to another Thread, transferring the ownership to the recipient.-
Methods inherited from class io.netty5.channel.DefaultAddressedEnvelope
content, recipient, sender, toString
-
-
-
-
Method Detail
-
send
public Send<T> send()
Description copied from interface:ResourceSend this object instance to another Thread, transferring the ownership to the recipient.The object must be in a state where it can be sent, which includes at least being accessible.
When sent, this instance will immediately become inaccessible, as if by closing it. All attempts at accessing an object that has been sent, even if that object has not yet been received, should cause an exception to be thrown.
Calling
Resource.close()on an object that has been sent will have no effect, so this method is safe to call within a try-with-resources statement.- Specified by:
sendin interfaceResource<A extends SocketAddress>
-
replace
public abstract T replace(Buffer content)
Create a new addressed envelope instance, that has the same recipient and sender as this one, but the given content.- Parameters:
content- The contents of the returned addressed envelope instance.- Returns:
- An addressed envelope instance that has the same recipient and sender as this one, but the given content.
-
close
public void close()
Description copied from interface:ResourceClose the resource, making it inaccessible.Note, this method is not thread-safe unless otherwise specified.
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceResource<A extends SocketAddress>
-
isAccessible
public boolean isAccessible()
Description copied from interface:ResourceCheck if this object is accessible.- Specified by:
isAccessiblein interfaceResource<A extends SocketAddress>- Returns:
trueif this object is still valid and can be accessed, otherwisefalseif, for instance, this object has been dropped/deallocated, or been sent elsewhere.
-
-