Esempio n. 1
0
 /// <summary>
 /// Applies the context changes over thread pool.
 /// </summary>
 private void ApplyContextChangesOverThreadPool(LinkChain <ContextChange> changeChain)
 {
     unchecked
     {
         ContextChange nextLink;
         ContextChange context      = changeChain.Head;
         int           contextCount = changeChain.Count;
         int           contextIndex;
         for (contextIndex = 0; contextIndex <= (contextCount - 5); contextIndex += 5)
         {
             ContextChange context0 = context; nextLink = context0.NextLink; context0.NextLink = null;  //+ paranoia
             ContextChange context1 = nextLink; nextLink = context1.NextLink; context1.NextLink = null; //+ paranoia
             ContextChange context2 = nextLink; nextLink = context2.NextLink; context2.NextLink = null; //+ paranoia
             ContextChange context3 = nextLink; nextLink = context3.NextLink; context3.NextLink = null; //+ paranoia
             ContextChange context4 = nextLink; nextLink = context4.NextLink; context4.NextLink = null; //+ paranoia
             context = nextLink;
             _threadPool.Add(new ContextChange[] { context0, context1, context2, context3, context4 });
         }
         if (contextIndex != contextCount)
         {
             contextCount -= contextIndex;
             ContextChange[] contextArray = new ContextChange[contextCount];
             contextIndex = 0;
             //for (; context != null; context = nextLink)
             for (; contextIndex < contextCount; context = nextLink)
             {
                 nextLink = context.NextLink; context.NextLink = null; //+ paranoia
                 contextArray[contextIndex++] = context;
             }
             _threadPool.Add(contextArray);
         }
         //+ clear
         changeChain.Clear();
     }
 }
Esempio n. 2
0
 /// <summary>
 /// Applies the context changes inline.
 /// </summary>
 private void ApplyContextChangesInline(LinkChain <ContextChange> changeChain)
 {
     unchecked
     {
         ContextChange nextLink;
         for (ContextChange context = changeChain.Head; context != null; context = nextLink)
         {
             nextLink = context.NextLink; context.NextLink = null; //+ paranoia
             context.Execute(null);
         }
         //+ clear
         changeChain.Clear();
     }
 }