Example #1
0
 private void Start()
 {
     if (_instance == null || _instance != this)
     {
         _instance = this;
     }
 }
        /// <summary>
        /// Removes the given Ids from the transaction list
        /// </summary>
        /// <param name="sceneParts"></param>
        public void EndTransaction(List<uint> sceneParts, SceneTransaction transaction)
        {
            lock (_threadsInTransactions)
            {
                //the thread id MUST be in the collection at this point
                //since the transaction had to have started in order to end
                Dictionary<uint, int> threadIds = _threadsInTransactions[Thread.CurrentThread.ManagedThreadId];

                foreach (uint id in sceneParts)
                {
                    //the id must also exist or there is a bug somewhere
                    int useCount = threadIds[id];
                    if (useCount == 1)
                    {
                        this.InformPrimOfTransactionEnd(id, transaction.PostGroupUpdatesUponCompletion);
                        threadIds.Remove(id);
                    }
                    else
                    {
                        threadIds[id] = useCount - 1;
                    }
                }

                //is our thread holding any more ids?
                if (threadIds.Count == 0)
                {
                    // if not, remove us
                    _threadsInTransactions.Remove(Thread.CurrentThread.ManagedThreadId);
                }

                Monitor.PulseAll(_threadsInTransactions);
            }
        }