示例#1
0
文件: Logger.cs 项目: sotaria/gsf
 private static void GrowStackDisposal(int desiredSize)
 {
     //Since these depths are relatively small, growing them both together has minor consequence.
     lock (SyncRoot)
     {
         while (s_stackDisposalStackMessages == null || s_stackDisposalStackMessages.Length < desiredSize)
         {
             //Note: both are grown together and completely reinitialized to improve
             //      locality of reference.
             int             lastSize      = s_stackDisposalStackMessages?.Length ?? 2;
             StackDisposal[] stackMessages = new StackDisposal[lastSize * 2];
             for (int x = 0; x < stackMessages.Length; x++)
             {
                 stackMessages[x] = new StackDisposal(x, DisposeStackMessage);
             }
             StackDisposal[] suppressionFlags = new StackDisposal[lastSize * 2];
             for (int x = 0; x < suppressionFlags.Length; x++)
             {
                 suppressionFlags[x] = new StackDisposal(x, DisposeSuppressionFlags);
             }
             s_stackDisposalStackMessages    = stackMessages;
             s_stackDisposalSuppressionFlags = suppressionFlags;
         }
     }
 }
示例#2
0
 private static void GrowStackDisposal(int desiredSize)
 {
     //Since these depths are relatively small, growing them both together has minor consequence.
     lock (SyncRoot)
     {
         while (s_stackDisposalStackMessages == null || s_stackDisposalStackMessages.Length < desiredSize)
         {
             //Note: both are grown together and completely reinitialized to improve 
             //      locality of reference.
             int lastSize = s_stackDisposalStackMessages?.Length ?? 2;
             StackDisposal[] stackMessages = new StackDisposal[lastSize * 2];
             for (int x = 0; x < stackMessages.Length; x++)
             {
                 stackMessages[x] = new StackDisposal(x, DisposeStackMessage);
             }
             StackDisposal[] suppressionFlags = new StackDisposal[lastSize * 2];
             for (int x = 0; x < suppressionFlags.Length; x++)
             {
                 suppressionFlags[x] = new StackDisposal(x, DisposeSuppressionFlags);
             }
             s_stackDisposalStackMessages = stackMessages;
             s_stackDisposalSuppressionFlags = suppressionFlags;
         }
     }
 }