public ImmediateTaskResult(BaseTaskResult owner, IThreadPool threadpool, IThreadPoolResult result) : base(threadpool, result)
 {
     owner.OnResult(value =>
     {
         this.Result = value;
     });
 }
Esempio n. 2
0
 /// <summary>
 /// Initializes an actor system with specified thread pool.
 /// </summary>
 public ActorSystem(string name, IThreadPool threadPool)
 {
     Name          = NotBlank(name, nameof(name));
     _threadPool   = NotNull(threadPool, nameof(threadPool));
     _actorFactory = new ConcurrentDictionary <Type, Func <object> >();
     _actors       = new Dictionary <string, IActorRef>();
 }
Esempio n. 3
0
            /// <summary>
            /// Initializes a new instance of the <see cref="MethodProxyBase"/> class.
            /// </summary>
            /// <param name="info">The info.</param>
            /// <param name="threadPool">The thread pool.</param>
            protected MethodProxyBase(MethodInfo info, IThreadPool threadPool)
            {
                _info       = info;
                _threadPool = threadPool;

                AddMetadataFrom(_info);
            }
 public DecompressOperationExecutor(IThreadPool threadPool, IBufferPool bufferPool, IBlockStreamWriter blockStreamWriter, ILogger logger)
 {
     this.threadPool        = threadPool;
     this.bufferPool        = bufferPool;
     this.blockStreamWriter = blockStreamWriter;
     this.logger            = logger;
 }
        protected void CheckResumeMenuInternal(MediaItem item)
        {
            IResumeState    resumeState = null;
            IUserManagement userProfileDataManagement = ServiceRegistration.Get <IUserManagement>();

            if (userProfileDataManagement.IsValidUser)
            {
                string resumeStateString;
                if (userProfileDataManagement.UserProfileDataManagement.GetUserMediaItemData(userProfileDataManagement.CurrentUser.ProfileId, item.MediaItemId, PlayerContext.KEY_RESUME_STATE, out resumeStateString))
                {
                    resumeState = ResumeStateBase.Deserialize(resumeStateString);
                }
            }

            if (resumeState == null)
            {
                // Asynchronously leave the current workflow state because we're called from a workflow model method
                IThreadPool threadPool = ServiceRegistration.Get <IThreadPool>();
                threadPool.Add(() =>
                {
                    LeaveCheckResumePlaybackSingleItemState();
                    PlayItem(item);
                });
                return;
            }
            _playMenuItems = new ItemsList();
            ListItem resumeItem = new ListItem
            {
                Command = new MethodDelegateCommand(() =>
                {
                    LeaveCheckResumePlaybackSingleItemState();
                    PlayItem(item, resumeState);
                })
            };
            PositionResumeState positionResume = resumeState as PositionResumeState;

            if (positionResume != null)
            {
                string playbackResume = LocalizationHelper.Translate(Consts.RES_PLAYBACK_RESUME_TIME, positionResume.ResumePosition.ToString(@"hh\:mm\:ss"));
                resumeItem.SetLabel(Consts.KEY_NAME, playbackResume);
            }
            else
            {
                resumeItem.SetLabel(Consts.KEY_NAME, Consts.RES_PLAYBACK_RESUME);
            }
            _playMenuItems.Add(resumeItem);
            ListItem playItem = new ListItem(Consts.KEY_NAME, Consts.RES_PLAYBACK_FROMSTART)
            {
                Command = new MethodDelegateCommand(() =>
                {
                    LeaveCheckResumePlaybackSingleItemState();
                    PlayItem(item);
                })
            };

            _playMenuItems.Add(playItem);
            IScreenManager screenManager = ServiceRegistration.Get <IScreenManager>();

            screenManager.ShowDialog(Consts.DIALOG_PLAY_MENU, (dialogName, dialogInstanceId) => LeaveCheckResumePlaybackSingleItemState());
        }
Esempio n. 6
0
        private TcpServer(
            EndPoint endPoint,
            IThreadPool threadPool,
            Func <TcpPeer> peerFactory,
            TcpServerSettings settings)
        {
            try
            {
                EndPoint = endPoint;
                Settings = settings ?? TcpServerSettings.Default;
                var acceptArgs = new SocketAsyncEventArgs();
                acceptArgs.Completed += OnAcceptCompleted;
                _connections          = new ConcurrentDictionary <long, TcpServerConnection>();
                _actorSystem          = new ActorSystem(EndPoint.ToString(), threadPool);
                _actorSystem.RegisterFactoryOf(peerFactory);
                _tcpServerConnectionNumber = 0;
                _socket = new Socket(endPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
                _socket.Bind(endPoint);
                _socket.Listen(Settings.Backlog);
                _receiveBufferPool = new FixedArrayPool <byte>(Settings.ReceiveBufferSize, 10000);
                StartAccept(_socket, acceptArgs);
            }
            catch
            {
                if (_socket != null)
                {
                    _socket.Close();
                    _socket.Dispose();
                }

                throw;
            }
        }
Esempio n. 7
0
 public SocketInput(MemoryPool memory, IThreadPool threadPool, IBufferSizeControl bufferSizeControl = null)
 {
     _memory            = memory;
     _threadPool        = threadPool;
     _bufferSizeControl = bufferSizeControl;
     _awaitableState    = _awaitableIsNotCompleted;
 }
 public MultiThreadBlockCompressor(ICompressService compressService, IFileService fileService, ICompressionMetaDataService metaDataService, IThreadPool threadPool)
 {
     _compressService = compressService;
     _fileService     = fileService;
     _metaDataService = metaDataService;
     _threadPool      = threadPool;
 }
Esempio n. 9
0
 public DecompressFileReader(string fileName, long fileHeaderSize, IThreadPool threadPool, int concurrency)
 {
     this.fileName       = fileName;
     this.fileHeaderSize = fileHeaderSize;
     bag    = new DisposableBlockingBag <Stream>(concurrency);
     worker = new Worker(threadPool);
 }
        protected override void Init()
        {
            base.Init();

            _taskScheduler = new Thread(AutoCheck)
            {
                IsBackground = true
            };
            _taskScheduler.Start();

            _scaleOutTask = () =>
            {
                try
                {
                    TryAddNewEntry(Config.ScaleFactor - 1);
                    _logger.Info("scaleOut success");
                }
                catch (Exception ex)
                {
                    _logger.Error(ex, "scaleOut failed");
                }
                finally
                {
                    Interlocked.CompareExchange(ref _scalingOut, 1, 0);
                }
            };

            ThreadPool.IBuilder builder = ThreadPools.NewThreadPoolConfigBuilder();
            builder.SetMinSize(1).SetMaxSize(1);
            _taskExecutor = ThreadPools.NewThreadPool(builder.Build());
        }
Esempio n. 11
0
 public FeedJobsWorkItem(IThreadPool <IThreadPoolWorkItem> pool, CountdownEvent countdown, long count, bool local)
 {
     _pool      = pool;
     _countdown = countdown;
     _count     = count;
     _local     = local;
 }
Esempio n. 12
0
        public void ImportPlaylist()
        {
            ILogger logger = ServiceRegistration.Get <ILogger>();

            SaveSettings();
            string importFile = ImportFile;

            if (!File.Exists(importFile))
            {
                logger.Warn("PlaylistImportModel: Cannot import playlist, playlist file '{0}' does not exist", importFile);
                return;
            }
            logger.Info("PlaylistImportModel: Importing playlist '{0}'", importFile);
            IServerConnectionManager scm = ServiceRegistration.Get <IServerConnectionManager>();
            IContentDirectory        cd  = scm.ContentDirectory;

            if (cd == null)
            {
                logger.Warn("PlaylistImportModel: Cannot import playlist, the server is not connected");
                return;
            }
            IList <string> mediaFiles = M3U.ExtractFileNamesFromPlaylist(importFile);
            IThreadPool    threadPool = ServiceRegistration.Get <IThreadPool>();

            threadPool.Add(() => RunImportOperationAsync(cd, mediaFiles));
        }
Esempio n. 13
0
        bool m_isDisposed = false; // acquire m_schedulerLock

        #endregion Fields

        #region Constructors

        /// <summary>Constructs a new SerialQueue backed by the given ThreadPool</summary>
        /// <param name="threadpool">The threadpool to queue async actions to</param>
        public SerialQueue(IThreadPool threadpool)
        {
            if (threadpool == null)
                throw new ArgumentNullException("threadpool");

            m_threadPool = threadpool;
        }
Esempio n. 14
0
        static void LazySave()
        {
            System.Threading.Thread.Sleep(100); // This combines quick calls to Save into one Save operation
            IThreadPool tp = GlobalServiceProvider.Get <IThreadPool>();

            tp.Add(_Save); // Add the save operation to the thread pool
        }
Esempio n. 15
0
        /// <summary>
        /// Creates or removes <see cref="IIntervalWork"/> from <see cref="IThreadPool"/>.
        /// </summary>
        /// <param name="psc">IPlayerSlotController</param>
        /// <param name="starting"><c>true</c> if starting, <c>false</c> if stopping.</param>
        /// <returns><c>true</c> if work should be removed when done.</returns>
        private bool HandleTasks(IPlayerSlotController psc, bool starting)
        {
            IThreadPool threadPool = ServiceRegistration.Get <IThreadPool>();

            lock (_syncObj)
            {
                // On stop, abort background interval work
                if (!starting && _progressUpdateWorks.ContainsKey(psc))
                {
                    threadPool.RemoveIntervalWork(_progressUpdateWorks[psc].Work);
                    return(true);
                }

                // When starting, create an asynchronous work and exit here
                if (!_progressUpdateWorks.ContainsKey(psc))
                {
                    IntervalWork work = new IntervalWork(() => HandleScrobble(psc, true), UPDATE_INTERVAL);
                    threadPool.AddIntervalWork(work, false);
                    _progressUpdateWorks[psc] = new PositionWatcher {
                        Work = work
                    };
                }
            }
            return(false);
        }
Esempio n. 16
0
        public static IThreadPool CreatePool()
        {
            IThreadPool threadPool = null;

            threadPool = new WorkerThreadPool();
            return(threadPool);
        }
        public IThreadPool CreatePool()
        {
            IThreadPool threadPool = null;

            threadPool = new WorkerThreadPool(this._threads);
            return(threadPool);
        }
Esempio n. 18
0
        /// <summary>
        /// Check if the memory cache should be cleared and starts an online update of (file-) cached series information.
        /// </summary>
        private void CheckCacheAndRefresh()
        {
            if (DateTime.Now - _memoryCacheInvalidated <= MAX_MEMCACHE_DURATION)
            {
                return;
            }
            _memoryCache.Clear();
            _memoryCacheInvalidated = DateTime.Now;

            if (DateTime.Now - _lastRefresh <= MIN_REFRESH_INTERVAL)
            {
                return;
            }

            IThreadPool threadPool = ServiceRegistration.Get <IThreadPool>(false);

            if (threadPool != null)
            {
                ServiceRegistration.Get <ILogger>().Debug("SeriesTvDbMatcher: Refreshing local cache");
                threadPool.Add(() =>
                {
                    if (Init())
                    {
                        _tv.UpdateCache();
                    }
                });
            }
            _lastRefresh = DateTime.Now;
        }
Esempio n. 19
0
            /// <summary>
            /// Initializes a new instance of the <see cref="MethodProxyBase"/> class.
            /// </summary>
            /// <param name="info">The info.</param>
            /// <param name="threadPool">The thread pool.</param>
            protected MethodProxyBase(MethodInfo info, IThreadPool threadPool)
            {
                _info = info;
                _threadPool = threadPool;

                AddMetadataFrom(_info);
            }
        //Asynchronously performs a query using the specified filter
        protected void UpdateAsync()
        {
            //Avoid recursive calls, this can happen if the call to BeginUpdate
            //updates one of our properties, triggering another update
            if (_isUpdating)
            {
                return;
            }

            _isUpdating = true;
            try
            {
                OnBeginUpdate();
            }
            finally
            {
                _isUpdating = false;
            }

            //Check state is valid before invoking a thread pool thread
            if (Filter == null)
            {
                //Set target property to null if invalid to remove any previously assigned media items
                UpdateTargetProperty(null, QueryMode);
                return;
            }
            //Update using the thread pool
            IThreadPool tp = ServiceRegistration.Get <IThreadPool>();

            tp.Add(Update);
        }
Esempio n. 21
0
 public BaseTaskResult(IThreadPool threadpool, IThreadPoolResult result)
 {
     this.ThreadPool       = threadpool;
     this.ThreadPoolResult = result;
     this._result          = null;
     this._hasResult       = false;
     this._onResultList    = null;
 }
Esempio n. 22
0
 protected ScheduledTask(string name, Action <bool> callback, IThreadPool pool, ILogger perf)
 {
     Id            = Guid.NewGuid();
     this.Name     = name;
     this.callback = callback;
     this.pool     = pool;
     this.perf     = perf;
 }
Esempio n. 23
0
 public SequentialWorkItem(IThreadPool <IThreadPoolWorkItem> pool, CountdownEvent signal, long count)
 {
     _pool   = pool;
     _signal = signal;
     _count  = new PaddedInt64 {
         Value = count
     };
 }
Esempio n. 24
0
 public PoolFiber(IThreadPool pool, IExecutor executor)
 {
     _timer         = new Scheduler(this);
     _pool          = pool;
     _executor      = executor;
     CounterDequeue = Counter.Instance;
     CounterEnqueue = Counter.Instance;
 }
Esempio n. 25
0
        public TestShortTerm()
        {
            StartInfo info = new StartInfo {
                Timeout = 1, MinWorkerThreads = 1
            };

            _pool = ThreadPoolFactory.Create(info, "short term pool");
        }
Esempio n. 26
0
        public ResourceAccessModule(OwinMiddleware next) : base(next)
        {
            AddDefaultMimeTypes();
            IThreadPool threadPool = ServiceRegistration.Get <IThreadPool>();

            _tidyUpCacheWork = new IntervalWork(TidyUpResourceAccessorCache, CACHE_CLEANUP_INTERVAL);
            threadPool.AddIntervalWork(_tidyUpCacheWork, false);
        }
Esempio n. 27
0
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     DontDestroyOnLoad(gameObject);
 }
 public CompressFileReader(string fileName, int batchSize, IThreadPool threadPool, int concurrency)
 {
     worker           = new Worker(threadPool);
     this.fileName    = fileName;
     this.batchSize   = batchSize;
     producingBag     = new DisposableBlockingBag <Chunk>(concurrency);
     memoryMappedFile = MemoryMappedFile.CreateFromFile(fileName, FileMode.Open, null);
 }
Esempio n. 29
0
 public DualChannelListener(IThreadPool threadPool)
 {
     _threadPool = threadPool;
     if (_threadPool != null)
     {
         _threadPool.Initialize();
     }
 }
Esempio n. 30
0
 public PriorityTaskResult(BaseTaskResult owner, IThreadPool threadpool, IThreadPoolResult result, int priority) : base(threadpool, result)
 {
     this._priority = priority;
     owner.OnResult(value =>
     {
         this.Result = value;
     });
 }
Esempio n. 31
0
 public WideTree(ISearchCollection <NodeModel> searchMode, INodeProcessor <NodeModel> nodeProcessor, IPrune prune, IThreadPool threadPool)
 {
     this.searchCollection = searchMode;
     this.visitors         = new List <IVisitor>();
     this.prune            = prune;
     this.nodeProcessor    = nodeProcessor;
     this.threadPool       = threadPool;
 }
Esempio n. 32
0
 void OnApplicationQuit()
 {
     instance = null;
     while (stack.Count > 0)
     {
         stack.Pop().Dispose();
     }
     disposed = true;
 }
Esempio n. 33
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DispatcherImplementation"/> class.
        /// </summary>
        public BatchingDispatcher(IThreadPool threadPool)
        {
            _dispatcher = Dispatcher.CurrentDispatcher;
            _threadPool = threadPool;
            DefaultPriority = DispatcherPriority.Send;

            new Thread(SendBatchOfUpdates)
            {
                IsBackground = true
            }.Start();
        }
Esempio n. 34
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BackgroundTask"/> class.
        /// </summary>
        /// <param name="threadPool">The thread pool.</param>
        /// <param name="theDelegate">The delegate to execute.</param>
        public BackgroundTask(IThreadPool threadPool, Func<object> theDelegate)
        {
            if(threadPool == null)
                throw new ArgumentNullException("threadPool");

            if(theDelegate == null)
                throw new ArgumentNullException("theDelegate");

            _threadPool = threadPool;
            _theDelegate = theDelegate;
            _context = new BackgroundContext(this);
        }
 public KestrelThread(KestrelEngine engine)
 {
     _engine = engine;
     _appLifetime = engine.AppLifetime;
     _log = engine.Log;
     _threadPool = engine.ThreadPool;
     _loop = new UvLoopHandle(_log);
     _post = new UvAsyncHandle(_log);
     _thread = new Thread(ThreadStart);
     _thread.Name = "KestrelThread - libuv";
     QueueCloseHandle = PostCloseHandle;
 }
        public FilteredStreamAdapter(
            Stream filteredStream,
            MemoryPool2 memory,
            IKestrelTrace logger,
            IThreadPool threadPool)
        {
            SocketInput = new SocketInput(memory, threadPool);
            SocketOutput = new StreamSocketOutput(filteredStream, memory);

            _log = logger;
            _filteredStream = filteredStream;
            _socketInputStream = new SocketInputStream(SocketInput);

            var block = memory.Lease();
            // Use pooled block for copy
            _filteredStream.CopyToAsync(_socketInputStream, block).ContinueWith((task, state) =>
            {
                var returnedBlock = task.Result;
                returnedBlock.Pool.Return(returnedBlock);

                ((FilteredStreamAdapter)state).OnStreamClose(task);
            }, this);
        }
Esempio n. 37
0
        public SocketOutput(
            KestrelThread thread,
            UvStreamHandle socket,
            MemoryPool2 memory,
            Connection connection,
            long connectionId,
            IKestrelTrace log,
            IThreadPool threadPool,
            Queue<UvWriteReq> writeReqPool)
        {
            _thread = thread;
            _socket = socket;
            _connection = connection;
            _connectionId = connectionId;
            _log = log;
            _threadPool = threadPool;
            _tasksPending = new Queue<TaskCompletionSource<object>>(_initialTaskQueues);
            _tasksCompleted = new Queue<TaskCompletionSource<object>>(_initialTaskQueues);
            _writeContextPool = new Queue<WriteContext>(_maxPooledWriteContexts);
            _writeReqPool = writeReqPool;

            _head = memory.Lease();
            _tail = _head;
        }
Esempio n. 38
0
 public SocketInput(MemoryPool2 memory, IThreadPool threadPool)
 {
     _memory = memory;
     _threadPool = threadPool;
     _awaitableState = _awaitableIsNotCompleted;
 }
Esempio n. 39
0
 private void ShutdownFromInstantiateException(IThreadPool tp, QuartzScheduler qs, bool tpInited, bool qsInited)
 {
     try
     {
         if (qsInited)
         {
             qs.Shutdown(false);
         }
         else if (tpInited)
         {
             tp.Shutdown(false);
         }
     }
     catch (Exception e)
     {
         Log.Error("Got another exception while shutting down after instantiation exception", e);
     }
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="DispatcherImplementation"/> class.
 /// </summary>
 public DispatcherImplementation(IThreadPool threadPool)
 {
     _dispatcher = GetDispatcher();
     _threadPool = threadPool;
     DefaultPriority = DispatcherPriority.Send;
 }
Esempio n. 41
0
	    /// <summary>
	    /// Creates a scheduler using the specified thread pool and job store and
	    /// binds it for remote access.
	    /// </summary>
	    /// <param name="schedulerName">The name for the scheduler.</param>
	    /// <param name="schedulerInstanceId">The instance ID for the scheduler.</param>
	    /// <param name="threadPool">The thread pool for executing jobs</param>
	    /// <param name="jobStore">The type of job store</param>
	    /// <param name="idleWaitTime">The idle wait time. You can specify "-1" for
	    /// the default value, which is currently 30000 ms.</param>
	    public virtual void CreateScheduler(string schedulerName, string schedulerInstanceId, IThreadPool threadPool,
                                            IJobStore jobStore, TimeSpan idleWaitTime)
        {
            CreateScheduler(schedulerName, schedulerInstanceId, threadPool, jobStore, null, idleWaitTime);
        }
Esempio n. 42
0
 /// <summary>
 /// Construct new instance.
 /// </summary>
 /// <param name="pool"></param>
 /// <param name="executor"></param>
 public PoolFiber(IThreadPool pool, IExecutor executor)
 {
     _pool = pool;
     _executor = executor;
 }
Esempio n. 43
0
	    /// <summary>
	    /// Creates a scheduler using the specified thread pool and job store and
	    /// binds it for remote access.
	    /// </summary>
	    /// <param name="schedulerName">The name for the scheduler.</param>
	    /// <param name="schedulerInstanceId">The instance ID for the scheduler.</param>
	    /// <param name="threadPool">The thread pool for executing jobs</param>
	    /// <param name="jobStore">The type of job store</param>
	    /// <param name="schedulerPluginMap"></param>
	    /// <param name="idleWaitTime">The idle wait time. You can specify TimeSpan.Zero for
	    /// the default value, which is currently 30000 ms.</param>
	    public virtual void CreateScheduler(string schedulerName, string schedulerInstanceId, IThreadPool threadPool,
                                            IJobStore jobStore, IDictionary<string, ISchedulerPlugin> schedulerPluginMap, TimeSpan idleWaitTime)
		{
			CreateScheduler(
                schedulerName, schedulerInstanceId, threadPool, jobStore, schedulerPluginMap, idleWaitTime, DefaultBatchMaxSize, DefaultBatchTimeWindow);
		}
Esempio n. 44
0
 /// <summary>
 /// Construct new instance.
 /// </summary>
 /// <param name="pool"></param>
 /// <param name="executor"></param>
 public PoolFiber(IThreadPool pool, IExecutor executor)
 {
     _timer = new Scheduler(this);
     _pool = pool;
     _executor = executor;
 }
Esempio n. 45
0
	    /// <summary>
		/// Creates a scheduler using the specified thread pool and job store and
		/// binds it to RMI.
		/// </summary>
		/// <param name="schedulerName">The name for the scheduler.</param>
		/// <param name="schedulerInstanceId">The instance ID for the scheduler.</param>
		/// <param name="threadPool">The thread pool for executing jobs</param>
		/// <param name="jobStore">The type of job store</param>
		/// <param name="schedulerPluginMap"></param>
		/// <param name="idleWaitTime">The idle wait time. You can specify TimeSpan.Zero for
		/// the default value, which is currently 30000 ms.</param>
		/// <param name="dbFailureRetryInterval">The db failure retry interval.</param>
		public virtual void CreateScheduler(string schedulerName, string schedulerInstanceId, IThreadPool threadPool,
                                            IJobStore jobStore, IDictionary schedulerPluginMap, TimeSpan idleWaitTime,
		                                    TimeSpan dbFailureRetryInterval)
		{
			// Currently only one run-shell factory is available...
			IJobRunShellFactory jrsf = new StdJobRunShellFactory();

			// Fire everything up
			// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
			SchedulingContext schedCtxt = new SchedulingContext();
			schedCtxt.InstanceId = schedulerInstanceId;

			SchedulerSchedulerResources qrs = new SchedulerSchedulerResources();

			qrs.Name = schedulerName;
			qrs.InstanceId = schedulerInstanceId;
			qrs.JobRunShellFactory = jrsf;
			qrs.ThreadPool = threadPool;
			qrs.JobStore = jobStore;


            // add plugins
            if (schedulerPluginMap != null)
            {
                foreach (ISchedulerPlugin plugin in schedulerPluginMap.Values)
                {
                    qrs.AddSchedulerPlugin(plugin);
                }
            }

			SchedulerScheduler qs = new SchedulerScheduler(qrs, schedCtxt, idleWaitTime, dbFailureRetryInterval);

			ITypeLoadHelper cch = new CascadingClassLoadHelper();
			cch.Initialize();

			jobStore.Initialize(cch, qs.SchedulerSignaler);

			IScheduler scheduler = new StdScheduler(qs, schedCtxt);

            // Initialize plugins now that we have a Scheduler instance.
            if (schedulerPluginMap != null)
            {
                foreach (DictionaryEntry pluginEntry in schedulerPluginMap)
                {
                    ((ISchedulerPlugin)pluginEntry.Value).Initialize(
                            (string) pluginEntry.Key, scheduler);
                }
            }

			jrsf.Initialize(scheduler, schedCtxt);

			Log.Info(string.Format(CultureInfo.InvariantCulture, "Scheduler scheduler '{0}", scheduler.SchedulerName));

			Log.Info(string.Format(CultureInfo.InvariantCulture, "Scheduler scheduler version: {0}", qs.Version));

			SchedulerRepository schedRep = SchedulerRepository.Instance;

			qs.AddNoGCObject(schedRep); // prevents the repository from being
			// garbage collected

			schedRep.Bind(scheduler);
		}
Esempio n. 46
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MethodFactory"/> class.
 /// </summary>
 /// <param name="threadPool">The thread pool.</param>
 public MethodFactory(IThreadPool threadPool)
 {
     _threadPool = threadPool;
 }
Esempio n. 47
0
        /// <summary>
        /// Creates a scheduler using the specified thread pool and job store and
        /// binds it for remote access.
        /// </summary>
        /// <param name="schedulerName">The name for the scheduler.</param>
        /// <param name="schedulerInstanceId">The instance ID for the scheduler.</param>
        /// <param name="threadPool">The thread pool for executing jobs</param>
        /// <param name="threadExecutor">Thread executor.</param>
        /// <param name="jobStore">The type of job store</param>
        /// <param name="schedulerPluginMap"></param>
        /// <param name="idleWaitTime">The idle wait time. You can specify TimeSpan.Zero for
        /// the default value, which is currently 30000 ms.</param>
        /// <param name="dbFailureRetryInterval">The db failure retry interval.</param>
        /// <param name="maxBatchSize">The maximum batch size of triggers, when acquiring them</param>
        /// <param name="batchTimeWindow">The time window for which it is allowed to "pre-acquire" triggers to fire</param>
        public virtual void CreateScheduler(string schedulerName, string schedulerInstanceId, IThreadPool threadPool, IThreadExecutor threadExecutor,
                                            IJobStore jobStore, IDictionary<string, ISchedulerPlugin> schedulerPluginMap, TimeSpan idleWaitTime,
                                            TimeSpan dbFailureRetryInterval, int maxBatchSize, TimeSpan batchTimeWindow)
        {
            // Currently only one run-shell factory is available...
            IJobRunShellFactory jrsf = new StdJobRunShellFactory();

            // Fire everything u
            // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            threadPool.Initialize();

            QuartzSchedulerResources qrs = new QuartzSchedulerResources();

            qrs.Name = schedulerName;
            qrs.InstanceId = schedulerInstanceId;

            SchedulerDetailsSetter.SetDetails(threadPool, schedulerName, schedulerInstanceId);

            qrs.JobRunShellFactory = jrsf;
            qrs.ThreadPool = threadPool;
            qrs.ThreadExecutor= threadExecutor;
            qrs.JobStore = jobStore;
            qrs.MaxBatchSize = maxBatchSize;
            qrs.BatchTimeWindow = batchTimeWindow;

            // add plugins
            if (schedulerPluginMap != null)
            {
                foreach (ISchedulerPlugin plugin in schedulerPluginMap.Values)
                {
                    qrs.AddSchedulerPlugin(plugin);
                }
            }

            QuartzScheduler qs = new QuartzScheduler(qrs, idleWaitTime, dbFailureRetryInterval);

            ITypeLoadHelper cch = new SimpleTypeLoadHelper();
            cch.Initialize();

            SchedulerDetailsSetter.SetDetails(jobStore, schedulerName, schedulerInstanceId);
            jobStore.Initialize(cch, qs.SchedulerSignaler);

            IScheduler scheduler = new StdScheduler(qs);

            jrsf.Initialize(scheduler);

            qs.Initialize();

            // Initialize plugins now that we have a Scheduler instance.
            if (schedulerPluginMap != null)
            {
                foreach (var pluginEntry in schedulerPluginMap)
                {
                    pluginEntry.Value.Initialize(pluginEntry.Key, scheduler);
                }
            }

            Log.Info(string.Format(CultureInfo.InvariantCulture, "Quartz scheduler '{0}", scheduler.SchedulerName));

            Log.Info(string.Format(CultureInfo.InvariantCulture, "Quartz scheduler version: {0}", qs.Version));

            SchedulerRepository schedRep = SchedulerRepository.Instance;

            qs.AddNoGCObject(schedRep); // prevents the repository from being
            // garbage collected

            schedRep.Bind(scheduler);

            initialized = true;
        }
Esempio n. 48
0
 /// <summary>
 /// Creates a scheduler using the specified thread pool and job store and
 /// binds it for remote access.
 /// </summary>
 /// <param name="schedulerName">The name for the scheduler.</param>
 /// <param name="schedulerInstanceId">The instance ID for the scheduler.</param>
 /// <param name="threadPool">The thread pool for executing jobs</param>
 /// <param name="jobStore">The type of job store</param>
 /// <param name="idleWaitTime">The idle wait time. You can specify "-1" for
 /// the default value, which is currently 30000 ms.</param>
 /// <param name="dbFailureRetryInterval">The db failure retry interval.</param>
 public virtual void CreateScheduler(string schedulerName, string schedulerInstanceId, IThreadPool threadPool,
                                     IJobStore jobStore, TimeSpan idleWaitTime,
                                     TimeSpan dbFailureRetryInterval)
 {
     CreateScheduler(schedulerName, schedulerInstanceId, threadPool, jobStore, null, idleWaitTime, dbFailureRetryInterval);
 }
Esempio n. 49
0
 /// <summary>
 /// Create a pool fiber with the default thread pool and default executor.
 /// </summary>
 public PoolFiber(IThreadPool pool)
     : this(pool, new DefaultExecutor())
 {
 }
Esempio n. 50
0
 /// <summary> 
 /// Creates a scheduler using the specified thread pool and job store. This
 /// scheduler can be retrieved via DirectSchedulerFactory#GetScheduler()
 /// </summary>
 /// <param name="threadPool">
 /// The thread pool for executing jobs
 /// </param>
 /// <param name="jobStore">
 /// The type of job store
 /// </param>
 /// <throws>  SchedulerException </throws>
 /// <summary>           if initialization failed
 /// </summary>
 public virtual void CreateScheduler(IThreadPool threadPool, IJobStore jobStore)
 {
     CreateScheduler(DefaultSchedulerName, DefaultInstanceId, threadPool, jobStore);
     initialized = true;
 }
Esempio n. 51
0
	    /// <summary>
	    /// Creates a scheduler using the specified thread pool and job store and
	    /// binds it for remote access.
	    /// </summary>
	    /// <param name="schedulerName">The name for the scheduler.</param>
	    /// <param name="schedulerInstanceId">The instance ID for the scheduler.</param>
	    /// <param name="threadPool">The thread pool for executing jobs</param>
	    /// <param name="jobStore">The type of job store</param>
	    /// <param name="schedulerPluginMap"></param>
	    /// <param name="idleWaitTime">The idle wait time. You can specify TimeSpan.Zero for
	    ///     the default value, which is currently 30000 ms.</param>
	    /// <param name="maxBatchSize">The maximum batch size of triggers, when acquiring them</param>
	    /// <param name="batchTimeWindow">The time window for which it is allowed to "pre-acquire" triggers to fire</param>
	    public virtual void CreateScheduler(
	        string schedulerName,
	        string schedulerInstanceId,
	        IThreadPool threadPool,
	        IJobStore jobStore,
	        IDictionary<string, ISchedulerPlugin> schedulerPluginMap,
	        TimeSpan idleWaitTime,
	        int maxBatchSize,
	        TimeSpan batchTimeWindow)
	    {
	        CreateScheduler(schedulerName, schedulerInstanceId, threadPool, jobStore, schedulerPluginMap, idleWaitTime, maxBatchSize, batchTimeWindow, null);
	    }
Esempio n. 52
0
        /// <summary>
        /// Same as DirectSchedulerFactory#createScheduler(ThreadPool threadPool, JobStore jobStore),
        /// with the addition of specifying the scheduler name and instance ID. This
        /// scheduler can only be retrieved via DirectSchedulerFactory#getScheduler(String)
        /// </summary>
        /// <param name="schedulerName">The name for the scheduler.</param>
        /// <param name="schedulerInstanceId">The instance ID for the scheduler.</param>
        /// <param name="threadPool">The thread pool for executing jobs</param>
        /// <param name="jobStore">The type of job store</param>
        public virtual void CreateScheduler(string schedulerName, string schedulerInstanceId, IThreadPool threadPool,
		                                    IJobStore jobStore)
        {
            CreateScheduler(schedulerName, schedulerInstanceId, threadPool, jobStore, TimeSpan.Zero, TimeSpan.Zero);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="DispatcherImplementation"/> class.
 /// </summary>
 public DispatcherImplementation(IThreadPool threadPool)
 {
     _dispatcher = GetDispatcher();
     _threadPool = threadPool;
 }
Esempio n. 54
0
 /// <summary>
 /// Creates a scheduler using the specified thread pool and job store and
 /// binds it for remote access.
 /// </summary>
 /// <param name="schedulerName">The name for the scheduler.</param>
 /// <param name="schedulerInstanceId">The instance ID for the scheduler.</param>
 /// <param name="threadPool">The thread pool for executing jobs</param>
 /// <param name="threadExecutor">Thread executor.</param>
 /// <param name="jobStore">The type of job store</param>
 /// <param name="schedulerPluginMap"></param>
 /// <param name="idleWaitTime">The idle wait time. You can specify TimeSpan.Zero for
 /// the default value, which is currently 30000 ms.</param>
 /// <param name="dbFailureRetryInterval">The db failure retry interval.</param>
 public virtual void CreateScheduler(string schedulerName, string schedulerInstanceId, IThreadPool threadPool, IThreadExecutor threadExecutor,
                                     IJobStore jobStore, IDictionary<string, ISchedulerPlugin> schedulerPluginMap, TimeSpan idleWaitTime,
                                     TimeSpan dbFailureRetryInterval)
 {
     CreateScheduler(schedulerName, schedulerInstanceId, threadPool, threadExecutor, jobStore, schedulerPluginMap, idleWaitTime, dbFailureRetryInterval, DefaultBatchMaxSize, DefaultBatchTimeWindow);
 }
Esempio n. 55
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Procedure"/> class.
 /// </summary>
 /// <param name="info">The info.</param>
 /// <param name="threadPool">The thread pool.</param>
 public Procedure(MethodInfo info, IThreadPool threadPool)
     : base(info, threadPool)
 {
     _theDelegate = DelegateFactory.Create<DelegateFactory.LateBoundProc>(info);
 }
Esempio n. 56
0
 public ThreadPoolFiber(IThreadPool threadPool)
 {
     _Queue = new Queue<Action>();
     _ThreadPool = threadPool;
 }
Esempio n. 57
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Function"/> class.
 /// </summary>
 /// <param name="info">The info.</param>
 /// <param name="threadPool">The thread pool.</param>
 public Function(MethodInfo info, IThreadPool threadPool)
     : base(info, threadPool)
 {
     _theDelegate = DelegateFactory.Create<DelegateFactory.LateBoundFunc>(info);
 }