/// <summary>
 /// Adds an enitity update to the list of entities that are queued to be persisted
 /// </summary>
 /// <param name="changedEntity">The entity to be persisted</param>
 internal void AddEntityToPersisted(Entity changedEntity)
 {
     lock (entityQueueLock)
     {
         if (!EntitiesToPersist.Contains(changedEntity))
         {
             EntitiesToPersist.Add(changedEntity);
         }
     }
 }
 /// <summary>
 /// Thread worker function that performs the persisting steps for queued entities and attributes
 /// </summary>
 private void PersistChangedEntities()
 {
     while (true)
     {
         lock (entityQueueLock)
         {
             if (EntitiesToPersist.Count > 0)
             {
                 CommitCurrentEntityUpdates();
                 EntitiesToPersist.Clear();
             }
         }
         lock (attributeQueueLock)
         {
             if (ComponentAttributesToPersist.Count > 0)
             {
                 CommitCurrentAttributeUpdates();
                 ComponentAttributesToPersist.Clear();
             }
         }
         Thread.Sleep(5);
     }
 }