/// <summary> /// Wait the specified deadline and data. /// </summary> /// <returns> /// <list type="bullet"> /// <item> /// <term>Ok</term> /// <description> /// on successful packet dequeuing. /// </description> /// </item> /// <item> /// <term>ErrBadHandle</term> /// <description> /// handle is not a valid handle. /// </description> /// </item> /// <item> /// <term>ErrInvalidArgs</term> /// <description> /// packet isn't a valid pointer /// </description> /// </item> /// <item> /// <term>ErrAccessDenied</term> /// <description> /// handle does not have ZX_RIGHT_READ and may not be waited upon. /// </description> /// </item> /// <item> /// <term>ErrTimedOut</term> /// <description> /// deadline passed and no packet was available. /// </description> /// </item> /// </list> /// </returns> /// <param name="deadline">Maximum amount of time to wait for a packet to arrive, if the timeout passes, the ZxStatus.TimedOut value will be returned.</param> /// <param name="data">The data that was retrieved from the port's queue.</param> /// <remarks> /// <para> /// Wait is a blocking syscall which causes the caller to wait until at least one packet is available. /// </para> /// /// <para> /// Upon return, if successful packet will contain the earliest (in FIFO order) available packet data. /// </para> /// /// <para> /// The deadline indicates when to stop waiting for a packet (with respect /// to ZxClock.Monotonic) and will be automatically adjusted according to /// the job's timer slack policy. If no packet has arrived by the /// deadline, ZxStatus.ErrTimedOut is returned. The value ZxTime.Infinite /// will result in waiting forever. A value in the past will result in an /// immediate timeout, unless a packet is already available for reading. /// </para> /// /// <para> /// Unlike Object.WaitOne and Object.WaitMany only one waiting thread is /// released (per available packet) which makes ports amenable to be /// serviced by thread pools. /// </para> /// /// <para> /// There are two classes of packets: packets queued by userspace with /// Queue() and packets queued by the kernel when objects a port /// is registered with change state. In both cases the packet is always of /// type ZxPortPacket /// </para> /// /// <para> /// In the case of packets generated via Queue(), type will be set /// to ZxPortPacketType.User, and the caller of Queue() controls all /// other values in the ZxPortPacket structure. Access to the packet /// data is provided by the user member, given by the ZxPacketUser. /// </para> /// /// <para> /// For packets generated by the kernel, type can be one of the following values: /// </para> /// <list type="bullet"> /// <item> /// <term>ZxPortPacketType.SignalOne, ZxPortPacketType.SignalRep</term> /// <description> /// generated by objects registered via zx_object_wait_async() /// </description> /// </item> /// <item> /// <term>PktTypeException</term> /// <description> /// generated by objects registered via zx_task_bind_exception_port() /// </description> /// </item> /// <item> /// <term>ZxPortPacketType.GuestBell, ZxPortPacketType.GuestMem, ZxPortPacketType.GuestVcpu, ZxPortPacketType.GuestIO</term> /// <description> /// generated by objects registered via zx_guest_set_trap(). /// </description> /// </item> /// <item> /// <term>ZxPortPacketType.Interrupt</term> /// <description> /// generated by objects registered via zx_interrupt_bind(). /// </description> /// </item> /// </list> /// <para>All kernel queued packets will have status set to ZxStatus.Ok and key set to the value provided to the registration syscall. /// For details on how to interpret the union, see the corresponding registration syscall. /// </para> /// </remarks> public ZxStatus Wait(ZxTime deadline, out ZxPortPacket data) { return(zx_port_wait((uint)handle, (ulong)deadline.NanoSeconds, out data)); }
/// <summary> /// Queue a packet to an port /// </summary> /// <returns> /// /// <list type="bullet"> /// <item> /// <term>Ok</term> /// <description> /// on successful queue of a packet. /// </description> /// </item> /// <item> /// <term>ErrBadHandle</term> /// <description> /// handle isn't a valid handle /// </description> /// </item> /// <item> /// <term>ErrInvalidArgs</term> /// <description> /// packet is an invalid pointer. /// </description> /// </item> /// <item> /// <term>ErrWrongType</term> /// <description> /// handle is not a port handle. /// </description> /// </item> /// <item> /// <term>ErrAccessDenied</term> /// <description> /// handle does not have ZX_RIGHT_WRITE. /// </description> /// </item> /// <item> /// <term>ErrShouldWait</term> /// <description> /// the port has too many pending packets. Once a thread has drained some packets a new zx_port_queue() call will likely succeed. /// </description> /// </item> /// </list> /// </returns> /// <param name="packet">Packet to queue into the port.</param> /// <remarks>The queue is drained by calling the Wait method.</remarks> public ZxStatus Queue(ref ZxPortPacket packet) { return(zx_port_queue((uint)handle, ref packet)); }
extern static ZxStatus zx_port_wait(uint handle, ulong deadline, out ZxPortPacket data);
extern static ZxStatus zx_port_queue(uint handle, ref ZxPortPacket data);