public ThreadedSerializationHandler(CommandMetaDataManager commandMetaDataManager)
        {
            this.commandMetaDataManager = commandMetaDataManager;

            messagesToSerialize          = new BlockingCollection <MessagesToSend>(new ConcurrentQueue <MessagesToSend>());
            serializedMessagesToSendPool = new ConcurrentPool <SerializedMessagesToSend>();
            messagesToSendPool           = new ConcurrentPool <MessagesToSend>();
            serializedMessages           = new ConcurrentQueue <SerializedMessagesToSend>();

            serialisationThread = new Thread(SerializeMessages);
            serialisationThread.Start();
        }
Exemplo n.º 2
0
        internal void ReturnEmptyStorageToPool(ConcurrentPool <CommandMetaData> pool)
        {
            for (int i = 0; i < metaData.Count; ++i)
            {
                if (!metaData[i].IsEmpty())
                {
                    continue;
                }

                pool.Return(metaData[i]);
                metaData.RemoveAt(i);
                ReturnEmptyStorageToPool(pool);
            }
        }