Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions src/ZeroMQ/Poller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,47 @@ public void ClearSockets()
CreatePollItems();
}

/// <summary>
/// Remove a socket that is polled for input/output events, depending on its capabilities.
/// </summary>
/// <param name="socket">The <see cref="ZmqSocket"/> to remove.</param>
/// <exception cref="ArgumentNullException"><paramref name="socket"/> is null.</exception>
/// <exception cref="ArgumentOutOfRangeException"><paramref name="socket"/> has no event handlers.</exception>
public void RemoveSocket(ZmqSocket socket)
{
if (socket == null)
{
throw new ArgumentNullException("socket");
}

var pollEvents = socket.GetPollEvents();

if (pollEvents == PollEvents.None)
{
throw new ArgumentOutOfRangeException("socket", "Unable to remove socket without at least one handler.");
}

_pollableSockets.Remove(new PollItem(socket.SocketHandle, pollEvents));
CreatePollItems();
}

/// <summary>
/// Remove a collection of sockets that is polled for input/output events, depending on their capabilities.
/// </summary>
/// <param name="sockets">The collection of <see cref="ZmqSocket"/>s to poll.</param>
public void RemoveSockets(IEnumerable<ZmqSocket> sockets)
{
if (sockets == null)
{
throw new ArgumentNullException("sockets");
}

foreach (var socket in sockets)
{
RemoveSocket(socket);
}
}

/// <summary>
/// Multiplex input/output events over the contained set of sockets in blocking mode, firing
/// <see cref="ZmqSocket.ReceiveReady" /> or <see cref="ZmqSocket.SendReady" /> as appropriate.
Expand Down