Esempio n. 1
0
        public void Run()
        {
            try
            {
                EPRuntimeImpl.ProcessStatementScheduleMultiple(_handle, _callbackObject, _services);

                // Let listeners know of results
                _runtime.Dispatch();

                // Work off the event queue if any events accumulated in there via a Route()
                _runtime.ProcessThreadWorkQueue();
            }
            catch (Exception e)
            {
                Log.Error("Unexpected error processing multiple timer execution: " + e.Message, e);
            }
        }
Esempio n. 2
0
        private void ProcessScheduleHandles(ArrayBackedCollection <ScheduleHandle> handles)
        {
            if (ThreadLogUtil.ENABLED_TRACE)
            {
                ThreadLogUtil.Trace("Found schedules for", handles.Count);
            }

            if (handles.Count == 0)
            {
                return;
            }

            // handle 1 result separatly for performance reasons
            if (handles.Count == 1)
            {
                Object[] handleArray = handles.Array;
                var      handle      = (EPStatementHandleCallback)handleArray[0];

                EPRuntimeImpl.ProcessStatementScheduleSingle(handle, _unisolatedServices);

                handles.Clear();
                return;
            }

            Object[] matchArray = handles.Array;
            int      entryCount = handles.Count;

            LinkedList <ScheduleHandleCallback> entries;

            // sort multiple matches for the event into statements
            var stmtCallbacks = SchedulePerStmt;

            stmtCallbacks.Clear();
            for (int i = 0; i < entryCount; i++)
            {
                var handleCallback = (EPStatementHandleCallback)matchArray[i];
                var handle         = handleCallback.AgentInstanceHandle;
                var callback       = handleCallback.ScheduleCallback;

                var entry = stmtCallbacks.Get(handle);

                // This statement has not been encountered before
                if (entry == null)
                {
                    stmtCallbacks.Put(handle, callback);
                    continue;
                }

                // This statement has been encountered once before
                if (entry is ScheduleHandleCallback)
                {
                    var existingCallback = (ScheduleHandleCallback)entry;
                    entries = new LinkedList <ScheduleHandleCallback>();
                    entries.AddLast(existingCallback);
                    entries.AddLast(callback);
                    stmtCallbacks.Put(handle, entries);
                    continue;
                }

                // This statement has been encountered more then once before
                entries = (LinkedList <ScheduleHandleCallback>)entry;
                entries.AddLast(callback);
            }
            handles.Clear();

            foreach (var entry in stmtCallbacks)
            {
                var handle         = entry.Key;
                var callbackObject = entry.Value;

                EPRuntimeImpl.ProcessStatementScheduleMultiple(handle, callbackObject, _unisolatedServices);

                if ((_isPrioritized) && (handle.IsPreemptive))
                {
                    break;
                }
            }
        }