private ProfileStorage(ConcurrentProfileStorageCollection pushTo, ServerEndPoint server, ProfileStorage resentFor, RetransmissionReasonType?reason)
 {
     PushToWhenFinished   = pushTo;
     OriginalProfiling    = resentFor;
     Server               = server;
     RetransmissionReason = reason;
 }
Exemple #2
0
        /// <summary>
        /// Registers the passed context with a collection that can be retried with subsequent calls to TryGetValue.
        ///
        /// Returns false if the passed context object is already registered.
        /// </summary>
        public bool TryCreate(object ctx)
        {
            var cell = ProfileContextCell.ToStoreUnder(ctx);

            // we can't pass this as a delegate, because TryAdd may invoke the factory multiple times,
            //   which would lead to over allocation.
            var storage = ConcurrentProfileStorageCollection.GetOrCreate();

            return(profiledCommands.TryAdd(cell, storage));
        }
Exemple #3
0
        /// <summary>
        /// Returns a ConcurrentProfileStorageCollection to use.
        ///
        /// It *may* have allocated a new one, or it may return one that has previously been released.
        /// To return the collection, call EnumerateAndReturnForReuse()
        /// </summary>
        public static ConcurrentProfileStorageCollection GetOrCreate()
        {
            ConcurrentProfileStorageCollection found;

            for (int i = 0; i < PoolSize; i++)
            {
                if ((found = Interlocked.Exchange(ref Pool[i], null)) != null)
                {
                    return(found);
                }
            }

            Interlocked.Increment(ref AllocationCount);
            found = new ConcurrentProfileStorageCollection();

            return(found);
        }
 public static ProfileStorage NewWithContext(ConcurrentProfileStorageCollection pushTo, ServerEndPoint server)
 {
     return(new ProfileStorage(pushTo, server, null, null));
 }
Exemple #5
0
        /// <summary>
        /// Returns true and sets val to the tracking collection associated with the given context if the context
        /// was registered with TryCreate.
        ///
        /// Otherwise returns false and sets val to null.
        /// </summary>
        public bool TryGetValue(object ctx, out ConcurrentProfileStorageCollection val)
        {
            var cell = ProfileContextCell.ToLookupBy(ctx);

            return(profiledCommands.TryGetValue(cell, out val));
        }