//private bool                              _IsDisposed;

        public ConcurrentFactory(SentSplitterConfig config, int instanceCount)
        {
            if (instanceCount <= 0)
            {
                throw (new ArgumentException("instanceCount"));
            }
            if (config == null)
            {
                throw (new ArgumentNullException("config"));
            }

            _Semaphore = new Semaphore(instanceCount, instanceCount);
            _Stack     = new ConcurrentStack <SentSplitter>();
            for (int i = 0; i < instanceCount; i++)
            {
                _Stack.Push(new SentSplitter(config));
            }
        }
Exemplo n.º 2
0
            public ConcurrentFactory GetConcurrentFactory()
            {
                var cf = _ConcurrentFactory;

                if (cf == null)
                {
                    lock ( _Lock )
                    {
                        cf = _ConcurrentFactory;
                        if (cf == null)
                        {
                            var config = new SentSplitterConfig()
                            {
                                Model             = new SentSplitterModel(Config.SENT_SPLITTER_RESOURCES_XML_FILENAME),
                                UrlDetectorConfig = new UrlDetectorConfig(Config.URL_DETECTOR_RESOURCES_XML_FILENAME),
                                SplitBySmiles     = true,
                            };
                            cf = new ConcurrentFactory(config, Config.CONCURRENT_FACTORY_INSTANCE_COUNT);
                            _ConcurrentFactory = cf;
                        }
                    }
                }
                return(cf);
            }