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);
            }
        }
Exemple #2
0
 public CommandMetaData GetEmptyMetaDataStorage()
 {
     return(pool.Rent());
 }
 public MessagesToSend GetMessagesToSendContainer()
 {
     return(messagesToSendPool.Rent());
 }