Beispiel #1
0
 internal IRDescEntry(InternalEventRouterDesc internalEventRouterDesc, InternalRoutePreprocessView outputView, IReaderWriterLock agentInstanceLock, bool hasSubselect)
 {
     _internalEventRouterDesc = internalEventRouterDesc;
     _outputView        = outputView;
     _agentInstanceLock = agentInstanceLock;
     _hasSubselect      = hasSubselect;
 }
Beispiel #2
0
 public EPDeploymentAdminImpl(
     EPAdministratorSPI epService,
     ILockManager lockManager,
     IReaderWriterLock eventProcessingRWLock,
     IResourceManager resourceManager,
     DeploymentStateService deploymentStateService,
     StatementEventTypeRef statementEventTypeRef,
     EventAdapterService eventAdapterService,
     StatementIsolationService statementIsolationService,
     FilterService filterService,
     TimeZoneInfo timeZone,
     ConfigurationEngineDefaults.UndeployRethrowPolicy undeployRethrowPolicy)
 {
     _iLock                     = lockManager.CreateDefaultLock();
     _epService                 = epService;
     _resourceManager           = resourceManager;
     _eventProcessingRwLock     = eventProcessingRWLock;
     _deploymentStateService    = deploymentStateService;
     _statementEventTypeRef     = statementEventTypeRef;
     _eventAdapterService       = eventAdapterService;
     _statementIsolationService = statementIsolationService;
     _filterService             = filterService;
     _timeZone                  = timeZone;
     _undeployRethrowPolicy     = undeployRethrowPolicy;
 }
 internal FilterParamIndexReboolNoValue(
     ExprFilterSpecLookupable lookupable,
     IReaderWriterLock readWriteLock)
     : base(FilterOperator.REBOOL, lookupable)
 {
     constantsMapRWLock = readWriteLock;
 }
Beispiel #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ObsoleteConcurrentDictionary&lt;K, V&gt;"/> class.
 /// </summary>
 public ObsoleteConcurrentDictionary(IReaderWriterLockManager rwLockManager)
 {
     _subDictionary = new Dictionary <K, V>();
     _rwLock        = rwLockManager.CreateLock(GetType());
     _rLock         = _rwLock.ReadLock;
     _wLock         = _rwLock.WriteLock;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ObsoleteConcurrentDictionary&lt;K, V&gt;"/> class.
 /// </summary>
 /// <param name="subDictionary">The sub dictionary.</param>
 public ObsoleteConcurrentDictionary(IDictionary <K, V> subDictionary)
 {
     _subDictionary = subDictionary;
     _rwLock        = ReaderWriterLockManager.CreateLock(GetType());
     _rLock         = _rwLock.ReadLock;
     _wLock         = _rwLock.WriteLock;
 }
        public static void Main()
        {
            rwl = new Locks.WriterReaderLock();
            // rwl = new Locks.ReaderWriterLock();

            var t = new Thread[numThreads];

            for (var i = 0; i < numThreads; i++)
            {
                t[i] = new Thread(new ThreadStart(ThreadProc))
                {
                    Name = new string(Convert.ToChar(i + 65), 1)
                };
                t[i].Start();
                if (i > 10)
                {
                    Thread.Sleep(300);
                }
            }

            running = false;
            for (var i = 0; i < numThreads; i++)
            {
                t[i].Join();
            }

            Console.WriteLine("\n{0} reads, {1} writes, {2} reader time-outs, {3} writer time-outs.",
                              reads, writes, readerTimeouts, writerTimeouts);
            Console.Write("Press ENTER to exit... ");
            Console.ReadLine();
        }
 public FilterServiceLockCoarse(
     IReaderWriterLockManager rwLockManager, 
     int stageId) : 
     base(FilterServiceGranularLockFactoryNone.Instance, stageId)
 {
     _lock = rwLockManager.CreateLock(GetType());
 }
 public SubordFullTableScanLookupStrategyLocking(
     IEnumerable<EventBean> contents,
     IReaderWriterLock statementLock)
 {
     this._contents = contents;
     this._statementLock = statementLock;
 }
Beispiel #9
0
        // settable for view-sharing

        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="stmtEngineServices">is the engine services for the statement</param>
        /// <param name="schedulingService">implementation for schedule registration</param>
        /// <param name="scheduleBucket">is for ordering scheduled callbacks within the view statements</param>
        /// <param name="epStatementHandle">is the statements-own handle for use in registering callbacks with services</param>
        /// <param name="viewResultionService">is a service for resolving view namespace and name to a view factory</param>
        /// <param name="patternResolutionService">is the service that resolves pattern objects for the statement</param>
        /// <param name="statementExtensionSvcContext">provide extension points for custom statement resources</param>
        /// <param name="statementStopService">for registering a callback invoked when a statement is stopped</param>
        /// <param name="methodResolutionService">is a service for resolving static methods and aggregation functions</param>
        /// <param name="patternContextFactory">is the pattern-level services and context information factory</param>
        /// <param name="filterService">is the filtering service</param>
        /// <param name="statementResultService">handles awareness of listeners/subscriptions for a statement customizing output produced</param>
        /// <param name="internalEventEngineRouteDest">routing destination</param>
        /// <param name="annotations">The annotations.</param>
        /// <param name="statementAgentInstanceRegistry">The statement agent instance registry.</param>
        /// <param name="defaultAgentInstanceLock">The default agent instance lock.</param>
        /// <param name="contextDescriptor">The context descriptor.</param>
        /// <param name="patternSubexpressionPoolSvc">The pattern subexpression pool SVC.</param>
        /// <param name="matchRecognizeStatePoolStmtSvc">The match recognize state pool statement SVC.</param>
        /// <param name="statelessSelect">if set to <c>true</c> [stateless select].</param>
        /// <param name="contextControllerFactoryService">The context controller factory service.</param>
        /// <param name="defaultAgentInstanceScriptContext">The default agent instance script context.</param>
        /// <param name="aggregationServiceFactoryService">The aggregation service factory service.</param>
        /// <param name="scriptingService">The scripting service.</param>
        /// <param name="writesToTables">if set to <c>true</c> [writes to tables].</param>
        /// <param name="statementUserObject">The statement user object.</param>
        /// <param name="statementSemiAnonymousTypeRegistry">The statement semi anonymous type registry.</param>
        /// <param name="priority">The priority.</param>
        public StatementContext(
            StatementContextEngineServices stmtEngineServices,
            SchedulingService schedulingService,
            ScheduleBucket scheduleBucket,
            EPStatementHandle epStatementHandle,
            ViewResolutionService viewResultionService,
            PatternObjectResolutionService patternResolutionService,
            StatementExtensionSvcContext statementExtensionSvcContext,
            StatementStopService statementStopService,
            MethodResolutionService methodResolutionService,
            PatternContextFactory patternContextFactory,
            FilterService filterService,
            StatementResultService statementResultService,
            InternalEventRouteDest internalEventEngineRouteDest,
            Attribute[] annotations,
            StatementAIResourceRegistry statementAgentInstanceRegistry,
            IReaderWriterLock defaultAgentInstanceLock,
            ContextDescriptor contextDescriptor,
            PatternSubexpressionPoolStmtSvc patternSubexpressionPoolSvc,
            MatchRecognizeStatePoolStmtSvc matchRecognizeStatePoolStmtSvc,
            bool statelessSelect,
            ContextControllerFactoryService contextControllerFactoryService,
            AgentInstanceScriptContext defaultAgentInstanceScriptContext,
            AggregationServiceFactoryService aggregationServiceFactoryService,
            ScriptingService scriptingService,
            bool writesToTables,
            object statementUserObject,
            StatementSemiAnonymousTypeRegistry statementSemiAnonymousTypeRegistry,
            int priority)
        {
            _stmtEngineServices               = stmtEngineServices;
            SchedulingService                 = schedulingService;
            ScheduleBucket                    = scheduleBucket;
            EpStatementHandle                 = epStatementHandle;
            ViewResolutionService             = viewResultionService;
            PatternResolutionService          = patternResolutionService;
            StatementExtensionServicesContext = statementExtensionSvcContext;
            StatementStopService              = statementStopService;
            MethodResolutionService           = methodResolutionService;
            PatternContextFactory             = patternContextFactory;
            FilterService                = filterService;
            _statementResultService      = statementResultService;
            InternalEventEngineRouteDest = internalEventEngineRouteDest;
            ScheduleAdjustmentService    = stmtEngineServices.ConfigSnapshot.EngineDefaults.ExecutionConfig.IsAllowIsolatedService ? new ScheduleAdjustmentService() : null;
            Annotations = annotations;
            StatementAgentInstanceRegistry = statementAgentInstanceRegistry;
            DefaultAgentInstanceLock       = defaultAgentInstanceLock;
            ContextDescriptor                 = contextDescriptor;
            PatternSubexpressionPoolSvc       = patternSubexpressionPoolSvc;
            MatchRecognizeStatePoolStmtSvc    = matchRecognizeStatePoolStmtSvc;
            IsStatelessSelect                 = statelessSelect;
            ContextControllerFactoryService   = contextControllerFactoryService;
            DefaultAgentInstanceScriptContext = defaultAgentInstanceScriptContext;
            AggregationServiceFactoryService  = aggregationServiceFactoryService;
            ScriptingService    = scriptingService;
            IsWritesToTables    = writesToTables;
            StatementUserObject = statementUserObject;
            StatementSemiAnonymousTypeRegistry = statementSemiAnonymousTypeRegistry;
            Priority = priority;
        }
Beispiel #10
0
 public SubordIndexedTableLookupStrategyLocking(
     SubordTableLookupStrategy inner,
     IReaderWriterLock statementLock)
 {
     this._inner = inner;
     this._statementLock = statementLock;
 }
Beispiel #11
0
 protected FilterParamIndexDoubleRangeBase(FilterSpecLookupable lookupable, IReaderWriterLock readWriteLock, FilterOperator filterOperator)
     : base(filterOperator, lookupable)
 {
     Ranges = new OrderedDictionary <DoubleRange, EventEvaluator>(new DoubleRangeComparator());
     _rangesNullEndpoints = new Dictionary <DoubleRange, EventEvaluator>();
     _rangesRwLock        = readWriteLock;
 }
Beispiel #12
0
 public FilterParamIndexIn(FilterSpecLookupable lookupable, IReaderWriterLock readWriteLock)
     : base(FilterOperator.IN_LIST_OF_VALUES, lookupable)
 {
     _constantsMap       = new Dictionary <Object, IList <EventEvaluator> >().WithNullSupport();
     _evaluatorsMap      = new Dictionary <MultiKeyUntyped, EventEvaluator>();
     _constantsMapRwLock = readWriteLock;
 }
Beispiel #13
0
        } /* End of Function - ReaderWriterLockManager */

        /************************ Methods ****************************************/
        /*----------------------- GetFor ----------------------------------------*/
        /// <inheritdoc />
        public IReaderWriterLock GetFor(TKey key)
        {
            m_logger.LogInformation($"Getting resource lock for key: {key}");
            IReaderWriterLock retval = null;

            lock (m_lock)
            {
                // Check to see if we have an item already for this
                // key
                if (m_readerWriters.ContainsKey(key))
                {
                    m_logger.LogInformation("Already have an object for the given key, retrieving...");
                    retval = m_readerWriters[key];
                }
                // Otherwise, create a new one and keep track of it
                // for next time
                else
                {
                    m_logger.LogInformation("Creating a new reader/writer lock resource for given key");
                    retval = m_factory.Create();
                    m_readerWriters.Add(key, retval);
                } // end of else - new item
            }     // end of lock - on resource
            m_logger.LogInformation($"Returning resource lock for key: {key}");
            return(retval);
        } /* End of Function - GetFor */
Beispiel #14
0
 public FilterServiceLockFine(
     IReaderWriterLockManager rwLockManager,
     int stageId) :
     base(new FilterServiceGranularLockFactoryReentrant(rwLockManager), stageId)
 {
     _lock = rwLockManager.CreateLock(GetType());
 }
Beispiel #15
0
 public EPStatementAgentInstanceHandle(EPStatementHandle statementHandle, IReaderWriterLock statementAgentInstanceLock, int agentInstanceId, StatementAgentInstanceFilterVersion statementFilterVersion)
 {
     StatementHandle             = statementHandle;
     _statementAgentInstanceLock = statementAgentInstanceLock;
     AgentInstanceId             = agentInstanceId;
     _hashCode = 31 * statementHandle.GetHashCode() + agentInstanceId;
     StatementFilterVersion = statementFilterVersion;
 }
 protected abstract NamedWindowDispatchService MakeNamedWindowDispatchService(
     SchedulingServiceSPI schedulingService,
     Configuration configurationSnapshot,
     IReaderWriterLock eventProcessingRWLock,
     ExceptionHandlingService exceptionHandlingService,
     VariableManagementService variableManagementService,
     TableManagementService tableManagementService,
     MetricReportingService metricReportingService);
Beispiel #17
0
 /// <summary>Logs the lock and action.</summary>
 /// <param name="lockAction">is the action towards the lock</param>
 /// <param name="lockObj">is the lock instance</param>
 public static void TraceLock(String lockAction, IReaderWriterLock @lockObj)
 {
     if (!ENABLED_TRACE)
     {
         return;
     }
     Write(lockAction + " " + GetLockInfo(lockObj));
 }
 /// <summary>
 ///     Initializes a new instance of the
 ///     <see cref="ConcurrentFilterableObservableMasterSlaveCollection{TItem, TFilter}" /> class.
 /// </summary>
 /// <param name="filteringPredicate">The filtering predicate.</param>
 /// <param name="context">The synchronization context to use, if any.</param>
 /// <exception cref="ArgumentNullException">
 ///     <paramref name="filteringPredicate" /> is <see langword="null" /> (
 ///     <see langword="Nothing" />) in Visual Basic.
 /// </exception>
 public ConcurrentFilterableObservableMasterSlaveCollection(
     Func <TItem, TFilter, bool> filteringPredicate,
     SynchronizationContext context)
     : base(context)
 {
     FilteringPredicate = Requires.NotNull(filteringPredicate);
     cacheLocker        = new ReaderWriterLockSlim(LockRecursionPolicy.NoRecursion);
 }
 public FilterServiceLockCoarse(
     ILockManager lockManager,
     IReaderWriterLockManager rwLockManager,
     bool allowIsolation)
     : base(lockManager, FilterServiceGranularLockFactoryNone.Instance, allowIsolation)
 {
     _iLock = rwLockManager.CreateLock(GetType());
 }
Beispiel #20
0
 public FilterParamIndexDoubleRange(FilterSpecLookupable lookupable, IReaderWriterLock readWriteLock, FilterOperator filterOperator)
     : base(lookupable, readWriteLock, filterOperator)
 {
     if (!(filterOperator.IsRangeOperator()))
     {
         throw new ArgumentException("Invalid filter operator " + filterOperator);
     }
 }
 public SafeEnumeratorWTableImpl(
     IReaderWriterLock iteratorLock,
     IEnumerator<E> underlying,
     TableExprEvaluatorContext tableExprEvaluatorContext)
     : base(iteratorLock, underlying)
 {
     this.tableExprEvaluatorContext = tableExprEvaluatorContext;
 }
 public FilterServiceLockFine(
     ILockManager lockManager,
     IReaderWriterLockManager rwLockManager,
     bool allowIsolation)
     : base(lockManager, new FilterServiceGranularLockFactoryReentrant(rwLockManager), allowIsolation)
 {
     _iLock = rwLockManager.CreateLock(GetType());
 }
Beispiel #23
0
        private static String GetLockInfo(IReaderWriterLock @lockObj)
        {
            String lockid = String.Format("RWLock@{0:X}", lockObj.GetHashCode());

            return(lockid +
                   //" readLockCount=" + lockObj.ReadLockCount +
                   " isWriteLocked=" + lockObj.IsWriterLockHeld);
        }
 /// <summary>
 ///     Initializes a new instance of the
 ///     <see cref="ConcurrentFilterableObservableMasterSlaveCollection{TItem, TFilter}" /> class.
 /// </summary>
 /// <param name="filteringPredicate">The filtering predicate.</param>
 /// <exception cref="ArgumentNullException">
 ///     <paramref name="filteringPredicate" /> is <see langword="null" /> (
 ///     <see langword="Nothing" />) in Visual Basic.
 /// </exception>
 /// <param name="suppressUndoable">If set to <see langword="true" />, suppresses undoable capabilities of this collection.</param>
 public ConcurrentFilterableObservableMasterSlaveCollection(
     Func <TItem, TFilter, bool> filteringPredicate,
     bool suppressUndoable)
     : base(suppressUndoable)
 {
     FilteringPredicate = Requires.NotNull(filteringPredicate);
     cacheLocker        = new ReaderWriterLockSlim(LockRecursionPolicy.NoRecursion);
 }
 public FilterParamIndexNotIn(FilterSpecLookupable lookupable, IReaderWriterLock readWriteLock)
     : base(FilterOperator.NOT_IN_LIST_OF_VALUES, lookupable)
 {
     _constantsMap          = new Dictionary <object, ISet <EventEvaluator> >().WithNullSupport();
     _filterValueEvaluators = new Dictionary <MultiKeyUntyped, EventEvaluator>();
     _evaluatorsSet         = new HashSet <EventEvaluator>();
     _constantsMapRwLock    = readWriteLock;
 }
Beispiel #26
0
 /// <summary>
 ///     Ctor.
 /// </summary>
 /// <param name="isFair">true if a fair @lock, false if not</param>
 public StatementAgentInstanceLockRW(bool isFair)
 {
     if (isFair) {
         _lock = new SlimReaderWriterLock();
     }
     else {
         _lock = new FairReaderWriterLock();
     }
 }
Beispiel #27
0
 public FilterParamIndexIn(
     ExprFilterSpecLookupable lookupable,
     IReaderWriterLock readWriteLock)
     : base(FilterOperator.IN_LIST_OF_VALUES, lookupable)
 {
     constantsMap = new HashMap<object, IList<EventEvaluator>>();
     evaluatorsMap = new HashMap<HashableMultiKey, EventEvaluator>();
     constantsMapRWLock = readWriteLock;
 }
Beispiel #28
0
 public IDisposable Acquire(IReaderWriterLock runtimeWideLock)
 {
     try {
         _lockDisposable = runtimeWideLock.WriteLock.Acquire((long) _timespan.TotalMilliseconds);
         return _lockDisposable;
     } catch (TimeoutException) { 
         throw new LockStrategyException("Failed to obtain write lock of runtime-wide processing read-write lock");
     }
 }
 protected FilterParamIndexNotEqualsBase(
     ExprFilterSpecLookupable lookupable,
     IReaderWriterLock readWriteLock,
     FilterOperator filterOperator)
     : base(filterOperator, lookupable)
 {
     ConstantsMap       = new Dictionary <object, EventEvaluator>().WithNullKeySupport();
     ConstantsMapRwLock = readWriteLock;
 }
 protected FilterParamIndexStringRangeBase(
     ExprFilterSpecLookupable lookupable,
     IReaderWriterLock readWriteLock,
     FilterOperator filterOperator)
     : base(filterOperator, lookupable)
 {
     Ranges        = new OrderedListDictionary <StringRange, EventEvaluator>(new StringRangeComparator());
     ReadWriteLock = readWriteLock;
 }
Beispiel #31
0
 public static bool UpgradeToWriterIf(IReaderWriterLock lok, RwLockGuardCondition condition)
 {
     if (condition())
       {
     lok.UpgradeToWriterLock();
     if (condition())
     {
       return true;
     }
       }
       return false;
 }
 public static ReaderWriterUsage FindUsage(IReaderWriterLock lok, bool createNew)
 {
     if (_usage == null)
       {
     _usage = new Dictionary<IReaderWriterLock, ReaderWriterUsage>();
     _usages = new List<ReaderWriterUsage>();
       }
       if (!_usage.ContainsKey(lok) || createNew)
       {
     _usage[lok] = new ReaderWriterUsage(lok);
     _usages.Add(_usage[lok]);
       }
       return _usage[lok];
 }
        private static void CreateReportRow(Report report, IReaderWriterLock  lok, IEnumerable<ReaderWriterUsage> usages)
        {
            long numberOfAcquires = 0;
              long numberOfReads = 0;
              long numberOfWrites = 0;
              long numberOfUpgrades = 0;
              long totalTicksInLock = 0;
              long totalTicksAsReader = 0;
              long totalTicksAsWriter = 0;
              long totalTicksWaiting = 0;
              long totalTicksWaitingToRead = 0;
              long totalTicksWaitingToWrite = 0;
              foreach (ReaderWriterUsage usage in usages)
              {
            if (usage.WasUpgraded)
            {
              numberOfUpgrades++;
            }
            if (usage.InitiallyAReader)
            {
              numberOfReads++;
            }
            else
            {
              numberOfWrites++;
            }
            numberOfAcquires++;
            totalTicksAsWriter += usage.TimeAsWriter;
            totalTicksAsReader += usage.TimeAsReader;
            totalTicksWaiting += usage.TimeWaitingToAcqure;
            totalTicksWaitingToRead += usage.TimeWaitingToRead;
            totalTicksWaitingToWrite += usage.TimeWaitingToWrite;
            totalTicksInLock += usage.TimeSpentInLock;
              }

              double frequency = (double)Stopwatch.Frequency / 1000.0;

              Report.Row row = report.AddRow();
              row.AddColumn("Acquires", numberOfAcquires);
              row.AddColumn("Reads", numberOfReads);
              row.AddColumn("Writes", numberOfWrites);
              row.AddColumn("Upgrades", numberOfUpgrades);
              row.AddColumn("WaitingToRead", totalTicksWaitingToRead / frequency);
              row.AddColumn("WaitingToWrite", totalTicksWaitingToWrite / frequency);
              row.AddColumn("Waiting", totalTicksWaiting / frequency);
              row.AddColumn("Lock", lok.Name);
        }
Beispiel #34
0
 public ReaderWriterUsage(IReaderWriterLock lok)
 {
     _lock = lok;
 }
Beispiel #35
0
 public static IDisposable AsWriter(IReaderWriterLock theLock)
 {
     theLock.AcquireWriterLock(Timeout.Infinite);
       return new RWLockWrapper(theLock);
 }
 public ReaderWriterLockedList(IReaderWriterLock readerWriterLock)
 {
     this.readerWriterLock = readerWriterLock;
 }
Beispiel #37
0
 public RWLockWrapper(IReaderWriterLock readerWriterLock)
 {
     _readerWriterLock = readerWriterLock;
 }