/// <summary> /// Initializes a new instance of the <see cref="CoCoL.ChannelNameAttribute"/> class. /// </summary> /// <param name="name">The name of the channel.</param> /// <param name="buffersize">The size of the buffer on the created channel</param> /// <param name="targetScope">The scope where the channel is created</param> /// <param name="maxPendingReaders">The maximum number of pending readers. A negative value indicates infinite</param> /// <param name="maxPendingWriters">The maximum number of pending writers. A negative value indicates infinite</param> /// <param name="pendingReadersOverflowStrategy">The strategy for dealing with overflow for read requests</param> /// <param name="pendingWritersOverflowStrategy">The strategy for dealing with overflow for write requests</param> public ChannelNameAttribute(string name, int buffersize = 0, ChannelNameScope targetScope = ChannelNameScope.Local, int maxPendingReaders = -1, int maxPendingWriters = -1, QueueOverflowStrategy pendingReadersOverflowStrategy = QueueOverflowStrategy.Reject, QueueOverflowStrategy pendingWritersOverflowStrategy = QueueOverflowStrategy.Reject) { Name = name; BufferSize = buffersize; TargetScope = targetScope; MaxPendingReaders = maxPendingReaders; MaxPendingWriters = maxPendingWriters; PendingReadersOverflowStrategy = pendingReadersOverflowStrategy; PendingWritersOverflowStrategy = pendingWritersOverflowStrategy; }
/// <summary> /// Creates a marker property for a read channel /// </summary> /// <returns>The marker instance.</returns> /// <param name="name">The name of the channel.</param> /// <param name="buffersize">The desired buffersize to use if the channel is created.</param> /// <param name="targetScope">The scope to create or locate the name in.</param> /// <typeparam name="T">The type of data passed on the channel.</typeparam> /// <param name="maxPendingReaders">The maximum number of pending readers. A negative value indicates infinite</param> /// <param name="maxPendingWriters">The maximum number of pending writers. A negative value indicates infinite</param> /// <param name="pendingReadersOverflowStrategy">The strategy for dealing with overflow for read requests</param> /// <param name="pendingWritersOverflowStrategy">The strategy for dealing with overflow for write requests</param> /// <param name="broadcast"><c>True</c> will create the channel as a broadcast channel, the default <c>false</c> will create a normal channel</param> /// <param name="initialBroadcastBarrier">The number of readers required on the channel before sending the first broadcast, can only be used with broadcast channels</param> /// <param name="broadcastMinimum">The minimum number of readers required on the channel, before a broadcast can be performed, can only be used with broadcast channels</param> public static IReadChannel <T> ForRead <T>(string name, int buffersize = 0, ChannelNameScope targetScope = ChannelNameScope.Local, int maxPendingReaders = -1, int maxPendingWriters = -1, QueueOverflowStrategy pendingReadersOverflowStrategy = QueueOverflowStrategy.Reject, QueueOverflowStrategy pendingWritersOverflowStrategy = QueueOverflowStrategy.Reject, bool broadcast = false, int initialBroadcastBarrier = -1, int broadcastMinimum = -1) { if (broadcast) { return(ForRead <T>(new BroadcastChannelNameAttribute(name, buffersize, targetScope, maxPendingReaders, maxPendingWriters, pendingReadersOverflowStrategy, pendingWritersOverflowStrategy, initialBroadcastBarrier, broadcastMinimum))); } if (initialBroadcastBarrier >= 0 || broadcastMinimum >= 0) { throw new ArgumentException(string.Format("Cannot set \"{0}\" or \"{1}\" unless the channel is a broadcast channel", "initialBroadcastBarrier", "broadcastMinimum")); } return(ForRead <T>(new ChannelNameAttribute(name, buffersize, targetScope, maxPendingReaders, maxPendingWriters, pendingReadersOverflowStrategy, pendingWritersOverflowStrategy))); }
/// <summary> /// Initializes a new instance of the <see cref="CoCoL.BroadcastChannelNameAttribute"/> class. /// </summary> /// <param name="name">The name of the channel.</param> /// <param name="buffersize">The size of the buffer on the created channel</param> /// <param name="targetScope">The scope where the channel is created</param> /// <param name="maxPendingReaders">The maximum number of pending readers. A negative value indicates infinite</param> /// <param name="maxPendingWriters">The maximum number of pending writers. A negative value indicates infinite</param> /// <param name="pendingReadersOverflowStrategy">The strategy for dealing with overflow for read requests</param> /// <param name="pendingWritersOverflowStrategy">The strategy for dealing with overflow for write requests</param> /// <param name="initialBarrierSize">The number of readers required on the channel before sending the first broadcast</param> /// <param name="minimumReaders">The minimum number of readers required on the channel, before a broadcast can be performed</param> public BroadcastChannelNameAttribute(string name, int buffersize = 0, ChannelNameScope targetScope = ChannelNameScope.Local, int maxPendingReaders = -1, int maxPendingWriters = -1, QueueOverflowStrategy pendingReadersOverflowStrategy = QueueOverflowStrategy.Reject, QueueOverflowStrategy pendingWritersOverflowStrategy = QueueOverflowStrategy.Reject, int initialBarrierSize = -1, int minimumReaders = -1) : base(name, buffersize, targetScope, maxPendingReaders, maxPendingWriters, pendingReadersOverflowStrategy, pendingWritersOverflowStrategy) { InitialBarrierSize = initialBarrierSize; MinimumReaders = minimumReaders; }
/// <summary> /// Initializes a new instance of the <see cref="T:CoCoL.ChannelMarkerWrapper<T>"/> class, /// </summary> /// <param name="name">The name of the channel.</param> /// <param name="buffersize">The size of the buffer on the created channel</param> /// <param name="targetScope">The scope where the channel is created</param> /// <param name="maxPendingReaders">The maximum number of pending readers. A negative value indicates infinite</param> /// <param name="maxPendingWriters">The maximum number of pending writers. A negative value indicates infinite</param> /// <param name="pendingReadersOverflowStrategy">The strategy for dealing with overflow for read requests</param> /// <param name="pendingWritersOverflowStrategy">The strategy for dealing with overflow for write requests</param> public ChannelMarkerWrapper(string name, int buffersize = 0, ChannelNameScope targetScope = ChannelNameScope.Local, int maxPendingReaders = -1, int maxPendingWriters = -1, QueueOverflowStrategy pendingReadersOverflowStrategy = QueueOverflowStrategy.Reject, QueueOverflowStrategy pendingWritersOverflowStrategy = QueueOverflowStrategy.Reject) : this(new ChannelNameAttribute(name, buffersize, targetScope, maxPendingReaders, maxPendingWriters, pendingReadersOverflowStrategy, pendingWritersOverflowStrategy)) { }