Example #1
0
        private void SendDispatchLoop()
        {
            while (true)
            {
                if (scheduler.Verbose)
                {
                    Console.WriteLine("Waiting for the next send to dispatch");
                }

                SendTask sendTask = sendQueue.Receive();

                if (scheduler.Verbose)
                {
                    Console.WriteLine("Dispatching send of message of size {0} to {1}",
                                      sendTask.Message.Length, IoScheduler.PublicKeyToString(sendTask.DestinationPublicKey));
                }

                SenderThread senderThread = scheduler.FindSenderForDestinationPublicKey(sendTask.DestinationPublicKey);

                if (senderThread == null)
                {
                    senderThread = ClientSenderThread.Create(scheduler, sendTask.DestinationPublicKey);
                }

                senderThread.EnqueueSendTask(sendTask);
            }
        }