Example #1
0
        public IPrioritizedProcessingGroup GetProcessingGroup(string transportId, string name, Action onFailure)
        {
            addId(transportId);
            var transport = Transport ?? (Transport = m_Factory.Create(m_TransportInfo, processTransportFailure));
            ProcessingGroupWrapper processingGroup;

            lock (m_ProcessingGroups)
            {
                processingGroup = m_ProcessingGroups.FirstOrDefault(g => g.TransportId == transportId && g.Name == name);

                if (processingGroup == null)
                {
                    ProcessingGroupInfo processingGroupInfo;
                    if (!m_TransportInfo.ProcessingGroups.TryGetValue(name, out processingGroupInfo))
                    {
                        processingGroupInfo = new ProcessingGroupInfo {
                            ConcurrencyLevel = 1
                        }
                    }
                    ;

                    processingGroup = new ProcessingGroupWrapper(transportId, name, processingGroupInfo);
                    processingGroup.SetProcessingGroup(transport.CreateProcessingGroup(() => processProcessingGroupFailure(processingGroup)));
                    m_ProcessingGroups.Add(processingGroup);
                }
            }

            if (onFailure != null)
            {
                processingGroup.OnFailure += onFailure;
            }
            return(processingGroup);
        }
Example #2
0
        public ProcessingGroupWrapper(string transportId, string name, ProcessingGroupInfo processingGroupInfo)
        {
            TransportId = transportId;
            Name        = name;
            var threadCount = Math.Max(processingGroupInfo.ConcurrencyLevel, 1);

            m_TaskScheduler = new QueuedTaskScheduler(threadCount);
            m_TaskFactories = new Dictionary <int, TaskFactory>();
        }