Exemple #1
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);
            }
        }
Exemple #2
0
 public void AddMetaData(CommandMetaData commandMetaData)
 {
     if (commandMetaData.IsEmpty())
     {
         pool.Return(commandMetaData);
     }
     else
     {
         lock (metaDataToAdd)
         {
             metaDataToAdd.Add(commandMetaData);
         }
     }
 }
        private void SerializeMessages()
        {
            // Block until a new message is available to serialize.
            while (messagesToSerialize.TryTake(out var messagesToSend, -1))
            {
                // If adding is complete then there is no reason to deserialize the message.
                if (messagesToSerialize.IsAddingCompleted)
                {
                    return;
                }

                SerializedMessagesToSend serialized = serializedMessagesToSendPool.Rent();
                CommandMetaData          metaData   = commandMetaDataManager.GetEmptyMetaDataStorage();

                // Serialize the messages and add them to the queue to be sent
                serialized.SerializeFrom(messagesToSend, metaData);
                messagesToSend.Clear();
                messagesToSendPool.Return(messagesToSend);
                serializedMessages.Enqueue(serialized);
            }
        }
 public void ReturnSerializedMessageContainer(SerializedMessagesToSend serializedMessagesToSend)
 {
     serializedMessagesToSendPool.Return(serializedMessagesToSend);
 }