Beispiel #1
0
        /// <summary>
        /// Updates the statistics for an <see cref="IMessageProcessor"/>.
        /// </summary>
        /// <param name="processorID">The ID of the <see cref="IMessageProcessor"/>.</param>
        /// <param name="bits">The number of bits read or written. Does not include the message ID.</param>
        public void HandleProcessorInvoked(MessageProcessorID processorID, int bits)
        {
            var ubits = (ushort)bits;

            // Check the bitsRead range
            if (bits < 0)
            {
                const string errmsg = "Invalid bitsRead value `{0}`.";
                if (log.IsErrorEnabled)
                {
                    log.ErrorFormat(errmsg, bits);
                }
                return;
            }

            if (bits < 0)
            {
                const string errmsg =
                    "Invalid bitsRead value `{0}` - value was too large to handle. Will use the largest possible value instead ({1}).";
                if (log.IsErrorEnabled)
                {
                    log.ErrorFormat(errmsg, bits, ushort.MaxValue);
                }
                ubits = ushort.MaxValue;
            }

            // Grab the stats
            ProcStats stats;

            lock (_statsSync)
            {
                if (!_stats.TryGetValue(processorID, out stats))
                {
                    stats = new ProcStats(processorID);
                    _stats[processorID] = stats;
                }
            }

            // Update the stats
            stats.NotifyCalled(ubits);

            // Check to dump the output
            if (_outFilePath != null && _nextDumpTime <= TickCount.Now)
            {
                _nextDumpTime = (TickCount)(TickCount.Now + _outDumpRate);
                Write(_outFilePath);
            }
        }
        /// <summary>
        /// Updates the statistics for an <see cref="IMessageProcessor"/>.
        /// </summary>
        /// <param name="processorID">The ID of the <see cref="IMessageProcessor"/>.</param>
        /// <param name="bits">The number of bits read or written. Does not include the message ID.</param>
        public void HandleProcessorInvoked(MessageProcessorID processorID, int bits)
        {
            var ubits = (ushort)bits;

            // Check the bitsRead range
            if (bits < 0)
            {
                const string errmsg = "Invalid bitsRead value `{0}`.";
                if (log.IsErrorEnabled)
                    log.ErrorFormat(errmsg, bits);
                return;
            }

            if (bits < 0)
            {
                const string errmsg =
                    "Invalid bitsRead value `{0}` - value was too large to handle. Will use the largest possible value instead ({1}).";
                if (log.IsErrorEnabled)
                    log.ErrorFormat(errmsg, bits, ushort.MaxValue);
                ubits = ushort.MaxValue;
            }

            // Grab the stats
            ProcStats stats;
            lock (_statsSync)
            {
                if (!_stats.TryGetValue(processorID, out stats))
                {
                    stats = new ProcStats(processorID);
                    _stats[processorID] = stats;
                }
            }

            // Update the stats
            stats.NotifyCalled(ubits);

            // Check to dump the output
            if (_outFilePath != null && _nextDumpTime <= TickCount.Now)
            {
                _nextDumpTime = (TickCount)(TickCount.Now + _outDumpRate);
                Write(_outFilePath);
            }
        }