Exemple #1
0
 private void QueueForExecutionOffThreadPool(ActorTask actorTask)
 {
     _thread?.Join();
     _thread =
         new Thread(Execute)
     {
         IsBackground = true,
         Name         = "ActorWorker"
     };
     _thread.Start(actorTask);
 }
Exemple #2
0
 private void QueueForExecution(ActorTask actorTask)
 {
     if ((actorTask.Task.CreationOptions & TaskCreationOptions.LongRunning) == 0)
     {
         QueueOnThreadPool(actorTask);
     }
     else
     {
         QueueForExecutionOffThreadPool(actorTask);
     }
 }
Exemple #3
0
        private void QueueTask(ActorTask actorTask)
        {
            TakeLock();

            switch (_status)
            {
            case ActorTaskSchedulerStatus.Terminated:
                ReleaseLock();
                CancelActorTask(actorTask);
                break;

            case ActorTaskSchedulerStatus.Inactive:
                _status = ActorTaskSchedulerStatus.Active;
                ReleaseLock();
                QueueForExecution(actorTask);
                break;

            case ActorTaskSchedulerStatus.Active:
                if ((actorTask.Traits & ActorTaskTraits.Resuming) == ActorTaskTraits.Resuming)
                {
                    actorTask.Next = _front;
                    _front         = actorTask;

                    if (_back is null)
                    {
                        _back = _front;
                    }
                }
                else
                {
                    if (_front is null)
                    {
                        _front = actorTask;
                    }
                    else
                    {
                        _back.Next = actorTask;
                    }

                    _back = actorTask;
                }

                ReleaseLock();

                break;

            case ActorTaskSchedulerStatus.Paused:
                if ((actorTask.Traits & ActorTaskTraits.Resuming) == ActorTaskTraits.Resuming)
                {
                    _status = ActorTaskSchedulerStatus.Active;
                    ReleaseLock();
                    QueueForExecution(actorTask);
                }
                else
                {
                    if (_front is null)
                    {
                        _front = actorTask;
                    }
                    else
                    {
                        _back.Next = actorTask;
                    }

                    _back = actorTask;
                    ReleaseLock();
                }

                break;
            }
        }
Exemple #4
0
        private void QueueOnThreadPool(ActorTask actorTask) =>
#if NETSTANDARD1_3
        ThreadPool.QueueUserWorkItem(Execute, actorTask);