コード例 #1
0
ファイル: WorkQueueProcessor.cs プロジェクト: hksonngan/Xian
        public WorkQueueProcessor(int numberThreads, ManualResetEvent terminateEvent, string name)
        {
            _terminateEvent = terminateEvent;
            _threadStop     = new ManualResetEvent(false);

            using (IReadContext ctx = PersistentStoreRegistry.GetDefaultStore().OpenReadContext())
            {
                IWorkQueueTypePropertiesEntityBroker  broker   = ctx.GetBroker <IWorkQueueTypePropertiesEntityBroker>();
                WorkQueueTypePropertiesSelectCriteria criteria = new WorkQueueTypePropertiesSelectCriteria();

                IList <WorkQueueTypeProperties> propertiesList = broker.Find(criteria);
                foreach (WorkQueueTypeProperties prop in propertiesList)
                {
                    _propertiesDictionary.Add(prop.WorkQueueTypeEnum, prop);
                }
            }


            _threadPool =
                new WorkQueueThreadPool(numberThreads,
                                        WorkQueueSettings.Instance.PriorityWorkQueueThreadCount,
                                        WorkQueueSettings.Instance.MemoryLimitedWorkQueueThreadCount,
                                        _propertiesDictionary)
            {
                ThreadPoolName = name + " Pool"
            };


            WorkQueueFactoryExtensionPoint ep = new WorkQueueFactoryExtensionPoint();

            object[] factories = ep.CreateExtensions();

            if (factories == null || factories.Length == 0)
            {
                // No extension for the workqueue processor.
                Platform.Log(LogLevel.Warn, "No WorkQueueFactory Extension found.");
            }
            else
            {
                foreach (object obj in factories)
                {
                    IWorkQueueProcessorFactory factory = obj as IWorkQueueProcessorFactory;
                    if (factory != null)
                    {
                        WorkQueueTypeEnum type = factory.GetWorkQueueType();
                        _extensions.Add(type, factory);
                    }
                    else
                    {
                        Platform.Log(LogLevel.Error, "Unexpected incorrect type loaded for extension: {0}",
                                     obj.GetType());
                    }
                }
            }
        }
コード例 #2
0
ファイル: WorkQueueProcessor.cs プロジェクト: nhannd/Xian
		public WorkQueueProcessor(int numberThreads, ManualResetEvent terminateEvent, string name)
        {
            _terminateEvent = terminateEvent;
            _threadStop = new ManualResetEvent(false);

			using (IReadContext ctx = PersistentStoreRegistry.GetDefaultStore().OpenReadContext())
			{
				IWorkQueueTypePropertiesEntityBroker broker = ctx.GetBroker<IWorkQueueTypePropertiesEntityBroker>();
				WorkQueueTypePropertiesSelectCriteria criteria = new WorkQueueTypePropertiesSelectCriteria();

				IList<WorkQueueTypeProperties> propertiesList = broker.Find(criteria);
				foreach (WorkQueueTypeProperties prop in propertiesList)
					_propertiesDictionary.Add(prop.WorkQueueTypeEnum, prop);
			}


			_threadPool =
				new WorkQueueThreadPool(numberThreads,
				                        WorkQueueSettings.Instance.PriorityWorkQueueThreadCount,
				                        WorkQueueSettings.Instance.MemoryLimitedWorkQueueThreadCount,
				                        _propertiesDictionary) {ThreadPoolName = name + " Pool"};


			WorkQueueFactoryExtensionPoint ep = new WorkQueueFactoryExtensionPoint();
            object[] factories = ep.CreateExtensions();

            if (factories == null || factories.Length == 0)
            {
                // No extension for the workqueue processor. 
                Platform.Log(LogLevel.Warn, "No WorkQueueFactory Extension found.");
            }
            else
            {
                foreach (object obj in factories)
                {
                    IWorkQueueProcessorFactory factory = obj as IWorkQueueProcessorFactory;
                    if (factory != null)
                    {
                        WorkQueueTypeEnum type = factory.GetWorkQueueType();
                        _extensions.Add(type, factory);
                    }
                    else
                        Platform.Log(LogLevel.Error, "Unexpected incorrect type loaded for extension: {0}",
                                     obj.GetType());
                }
            }
	    }