/// <summary> /// Initializes a new instance of the <see cref="CoCoL.SingleThreadedWorker"/> class. /// </summary> public SingleThreadedWorker() { AutomationExtensions.AutoWireChannels(this, null); m_channel = ChannelManager.CreateChannel <Func <Task> >(); m_workerSource = new CancellationTokenSource(); m_worker = AutomationExtensions.RunProtected(this, Start); }
/// <summary> /// Creates a channel, possibly unnamed. /// If a channel name is provided, the channel is created in the supplied scope. /// If a channel with the given name is already found in the supplied scope, the named channel is returned. /// </summary> /// <returns>The channel.</returns> /// <param name="name">The name of the channel, or null.</param> /// <param name="buffersize">The number of buffers in the channel.</param> /// <param name="scope">The scope to create a named channel in, defaults to null which means the current scope</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="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> /// <typeparam name="T">The channel type.</typeparam> public static IChannel <T> Create <T>(string name = null, int buffersize = 0, ChannelScope scope = null, int maxPendingReaders = -1, int maxPendingWriters = -1, QueueOverflowStrategy pendingReadersOverflowStrategy = QueueOverflowStrategy.Reject, QueueOverflowStrategy pendingWritersOverflowStrategy = QueueOverflowStrategy.Reject, bool broadcast = false, int initialBroadcastBarrier = -1, int broadcastMinimum = -1) { return(ChannelManager.CreateChannel <T>(name, buffersize, scope, maxPendingReaders, maxPendingWriters, pendingReadersOverflowStrategy, pendingWritersOverflowStrategy, broadcast, initialBroadcastBarrier, broadcastMinimum)); }
/// <summary> /// Creates a channel, possibly unnamed. /// If a channel name is provided, the channel is created in the supplied scope. /// If a channel with the given name is already found in the supplied scope, the named channel is returned. /// </summary> /// <returns>The named channel.</returns> /// <param name="attr">The attribute describing the channel.</param> /// <param name="scope">The scope to create a named channel in, defaults to null which means the current scope</param> /// <typeparam name="T">The channel type.</typeparam> public static IChannel <T> Create <T>(ChannelNameAttribute attr, ChannelScope scope = null) { return(ChannelManager.CreateChannel <T>(attr, scope)); }