public void AddPatternContext(String statementName,
                               PatternSubexpressionPoolStmtHandler stmtCounts)
 {
     lock (_patternContexts)
     {
         _patternContexts.Add(new StatementEntry(statementName, stmtCounts));
     }
 }
        public void DecreaseCount(EvalNode evalNode, AgentInstanceContext agentInstanceContext)
        {
            long newMax = _poolCount.DecrementAndGet();

            if ((ExecutionPathDebugLog.IsEnabled) && Log.IsDebugEnabled)
            {
                PatternSubexpressionPoolStmtHandler stmtHandler = agentInstanceContext.StatementContext.PatternSubexpressionPoolSvc.StmtHandler;
                String stmtName = agentInstanceContext.StatementContext.StatementName;
                Log.Debug(".decreaseCount For statement '" + stmtName + "' pool count decreases to " + newMax +
                          " statement count was " + stmtHandler.Count);
            }
        }
        public bool TryIncreaseCount(EvalNode evalNode, AgentInstanceContext agentInstanceContext)
        {
            // test pool max
            long newMax = _poolCount.IncrementAndGet();

            if (newMax > _maxPoolCountConfigured && _maxPoolCountConfigured >= 0)
            {
                var counts = Counts;
                agentInstanceContext.StatementContext.ExceptionHandlingService.HandleCondition(
                    new ConditionPatternEngineSubexpressionMax(_maxPoolCountConfigured, counts), agentInstanceContext.StatementContext.EpStatementHandle);
                if ((ExecutionPathDebugLog.IsEnabled) &&
                    (Log.IsDebugEnabled && (ExecutionPathDebugLog.IsTimerDebugEnabled)))
                {
                    PatternSubexpressionPoolStmtHandler stmtHandler = agentInstanceContext.StatementContext.PatternSubexpressionPoolSvc.StmtHandler;
                    String stmtName = agentInstanceContext.StatementContext.StatementName;
                    Log.Debug(".tryIncreaseCount For statement '" + stmtName + "' pool count overflow at " + newMax +
                              " statement count was " + stmtHandler.Count + " preventStart=" + _preventStart);
                }

                if (_preventStart)
                {
                    _poolCount.DecrementAndGet();
                    return(false);
                }

                return(true);
            }
            if ((ExecutionPathDebugLog.IsEnabled) && Log.IsDebugEnabled)
            {
                PatternSubexpressionPoolStmtHandler stmtHandler = agentInstanceContext.StatementContext.PatternSubexpressionPoolSvc.StmtHandler;
                String stmtName = agentInstanceContext.StatementContext.StatementName;
                Log.Debug(".tryIncreaseCount For statement '" + stmtName + "' pool count increases to " + newMax +
                          " statement count was " + stmtHandler.Count);
            }
            return(true);
        }
 public StatementEntry(String statementName,
                       PatternSubexpressionPoolStmtHandler stmtCounts)
 {
     StatementName = statementName;
     StmtCounts    = stmtCounts;
 }