Permalink
Browse files

Make some RecvAll methods Obsolete.

RecvAll is not compatible with using SendRecvOpt flags due to the
possibility of repeatedly queuing null results if NOBLOCK is specified.
These Obsolete methods will be removed in 3.x.
  • Loading branch information...
1 parent 167738d commit 4b1d096cda050eab12edcb8e5a360b90b2cc0798 John Gozde committed Dec 12, 2011
Showing with 30 additions and 5 deletions.
  1. +30 −5 src/clrzmq/Socket.cs
View
@@ -604,26 +604,50 @@ public class Socket : IDisposable {
/// <returns>Queue of message parts</returns>
/// <exception cref="ZMQ.Exception">ZMQ Exception</exception>
public Queue<byte[]> RecvAll() {
- return RecvAll(SendRecvOpt.NONE);
+ return RecvAll((Queue<byte[]>)null);
}
/// <summary>
/// Listen for message, retrieving all pending message parts
/// </summary>
+ /// <param name="messages">The queue object to put the message into</param>
+ /// <returns>Queue of message parts</returns>
+ /// <exception cref="ZMQ.Exception">ZMQ Exception</exception>
+ public Queue<byte[]> RecvAll(Queue<byte[]> messages) {
+ if (messages == null) {
+ messages = new Queue<byte[]>();
+ }
+
+ messages.Enqueue(Recv());
+ while (RcvMore) {
+ messages.Enqueue(Recv());
+ }
+ return messages;
+ }
+
+ /// <summary>
+ /// DO NOT USE. Left in for backward compatibility, but SendRecvOpt flags are
+ /// not compatible with RecvAll.
+ /// Listen for message, retrieving all pending message parts.
+ /// </summary>
/// <param name="flags">Receive options</param>
/// <returns>Queue of message parts</returns>
/// <exception cref="ZMQ.Exception">ZMQ Exception</exception>
+ [Obsolete("Will be removed in version 3.x.")]
public Queue<byte[]> RecvAll(params SendRecvOpt[] flags) {
return RecvAll((Queue<byte[]>)null, flags);
}
/// <summary>
- /// Listen for message, retrieving all pending message parts
+ /// DO NOT USE. Left in for backward compatibility, but SendRecvOpt flags are
+ /// not compatible with RecvAll.
+ /// Listen for message, retrieving all pending message parts.
/// </summary>
/// <param name="messages">The queue object to put the message into</param>
/// <param name="flags">Receive options</param>
/// <returns>Queue of message parts</returns>
/// <exception cref="ZMQ.Exception">ZMQ Exception</exception>
+ [Obsolete("Will be removed in version 3.x.")]
public Queue<byte[]> RecvAll(Queue<byte[]> messages, params SendRecvOpt[] flags) {
if (messages == null) {
messages = new Queue<byte[]>();
@@ -652,14 +676,15 @@ public class Socket : IDisposable {
}
/// <summary>
- /// Listen for message, retrieving all pending message parts. DO NOT
- /// USE, left for backwards compatibility reasons but the sendrecvopts
- /// are not compatible with receiving all messages.
+ /// DO NOT USE. Left in for backward compatibility, but SendRecvOpt flags are
+ /// not compatible with RecvAll.
+ /// Listen for message, retrieving all pending message parts.
/// </summary>
/// <param name="encoding">String Encoding</param>
/// <param name="flags">Socket options to use when receiving</param>
/// <returns>Queue of message parts</returns>
/// <exception cref="ZMQ.Exception">ZMQ Exception</exception>
+ [Obsolete("Will be removed in version 3.x.")]
public Queue<string> RecvAll(Encoding encoding, params SendRecvOpt[] flags) {
var messages = new Queue<string>();
messages.Enqueue(Recv(encoding, flags));

0 comments on commit 4b1d096

Please sign in to comment.