public TopicMessageBus( string connectionString, int partitionCount, int nodeCount, int nodeId, string prefix, Func <string, ulong, Message[], Task> onReceivedAsync) { this.prefix = prefix; this.connectionString = connectionString; this.partitionCount = partitionCount; this.nodeCount = nodeCount; this.nodeId = nodeId; this.factories = new Dictionary <int, MessagingFactory>(); this.pumps = new Dictionary <int, MessagePump>(); this.senders = new Dictionary <int, MessageSender>(); this.onReceivedAsync = onReceivedAsync; this.semaphore = new AsyncSemaphore(MaxInputQueueLength); this.inputQueue = new InputQueue <InternalMessage>(); this.initializeTask = Task.Factory.FromAsync( (c, s) => new InitializeAsyncResult(this, c, s).Start(), r => { InitializeAsyncResult.End(r); return(true); }, null); }
public MessagePump(string id, MessageReceiver receiver, InputQueue <InternalMessage> inputQueue, AsyncSemaphore semaphore) { this.id = id; this.receiver = receiver; this.inputQueue = inputQueue; this.semaphore = semaphore; this.exitSemaphore = new Action(ExitSemaphore); }
public AsyncQueueReader(InputQueue <T> inputQueue, TimeSpan timeout, AsyncCallback callback, object state) : base(callback, state) { if (inputQueue.AsyncCallbackGenerator != null) { this.VirtualCallback = new Action <AsyncCallback, IAsyncResult>(inputQueue.AsyncCallbackGenerator()); } this.inputQueue = inputQueue; if (timeout != TimeSpan.MaxValue) { this.timer = new IOThreadTimer(timerCallback, this, false); this.timer.Set(timeout); } }
public WaitQueueReader(InputQueue <T> inputQueue) { this.inputQueue = inputQueue; waitEvent = new ManualResetEvent(false); }
public MessageDispatcher(InputQueue <InternalMessage> inputQueue, Func <string, ulong, Message[], Task> onReceivedAsync) { this.inputQueue = inputQueue; this.onReceivedAsync = onReceivedAsync; }