Handle
open class Handle
Representation of a Venice resource like Coroutine
and Channel
.
-
Raw handle representing the resource.
Declaration
Swift
public var handle: HandleDescriptor
-
Initializes
Handle
with the raw handle.Declaration
Swift
public init(handle: HandleDescriptor)
Parameters
handle
Raw handle representing the resource.
-
This function is used to inform the handle that there will be no more input. This gives it time to finish it’s work and possibly inform the user when it is safe to close the handle.
For example, in case of TCP protocol handle, hdone sends out a FIN packet. However, it does not wait until it is acknowledged by the peer.
Warning
Afterdone
is called on a handle, any attempts to send more data to the handle will result in aVeniceError.handleIsDone
error.Warning
Handle implementation may also decide to prevent any further receiving of data and return
VeniceError.handleIsDone
error instead.Throws
The following errors might be thrown:
VeniceError.invalidHandle
Thrown when the operation is performed on an invalid handle.
VeniceError.operationNotSupported
Thrown when the operation is not supported.
VeniceError.handleIsDone
Thrown when the operation is performed on an done handle.
VeniceError.deadlineReached
Thrown when the operation reaches the deadline.
VeniceError.unexpectedError
Thrown when an unexpected error occurs. This should never happen in the regular flow of an application.
Declaration
Swift
open func done(deadline: Deadline) throws
Parameters
deadline
deadline
is a point in time when the operation should timeout. Use the.fromNow()
function to get the current point in time. Use.immediate
if the operation needs to be performed without blocking. Use.never
to allow the operation to block forever if needed. -
Closes the handle.
Warning
close
guarantees that all associated resources are deallocated. However, it does not guarantee that the handle’s work will have been fully finished. For example, outbound network data may not be flushed.Throws
The following errors might be thrown:
VeniceError.invalidHandle
Thrown when the operation is performed on a invalid handle.
VeniceError.unexpectedError
Thrown when an unexpected error occurs. This should never happen in the regular flow of an application.
Declaration
Swift
open func close() throws