protected bool TryExecute(PerlaItem item) { if (item.ExecutingScheduler != this) { throw new InvalidOperationException("PerlaScheduler ExecuteMethod WrongScheduler"); } return(item.ExecuteEntry()); }
protected internal override void QueueTask(PerlaItem item) { if (item.ExcutionFlag != PerlaExcutionFlag.Single) { Thread thread = new Thread(s_longRunningThreadWork); thread.IsBackground = true; thread.Start(item); } }
internal void UpdateExceptionObservedStatus() { PerlaItem parent = m_parent; if ((parent != null) && PerlaItem.InternalCurrent == parent) { #warning NeedToWorkMore } }
protected override bool TryExecuteTaskInline(PerlaItem item, bool taskWasPreviouslyQueued) { if (SynchronizationContext.Current == m_synchronizationContext) { return(TryExecute(item)); } else { return(false); } }
internal static bool AddToActiveItems(PerlaItem item) { Debug.Assert(item != null, "Null PerlaItem objects can't be added to the ActiveItems collection"); LazyInitializer.EnsureInitialized(ref s_currentActiveItems, () => new Dictionary <int, PerlaItem>()); int itemId = item.Id; lock (s_currentActiveItems) { s_currentActiveItems[itemId] = item; } return(true); }
internal static void RemoveFromActiveItems(PerlaItem item) { if (s_currentActiveItems == null) { return; } int taskId = item.Id; lock (s_currentActiveItems) { s_currentActiveItems.Remove(taskId); } }
protected override bool TryExecuteTaskInline(PerlaItem item, bool taskWasPreviouslyQueued) { if (taskWasPreviouslyQueued /*&& !ThreadPool.TryPopCustomWorkItem(item)*/) { return(false); } try { item.ExecuteEntryUnsafe(threadPoolThread: null); } finally { if (taskWasPreviouslyQueued) { NotifyWorkItemProgress(); } } return(true); }
internal bool TryRunInline(PerlaItem item, bool taskWasPreviouslyQueued) { PerlaScheduler ets = item.ExecutingScheduler; if (ets != this && ets != null) { return(ets.TryRunInline(item, taskWasPreviouslyQueued)); } if ((ets == null) || (item.m_action == null) || item.IsDelegateInvoked || item.IsCanceled) { return(false); } bool inlined = TryExecuteTaskInline(item, taskWasPreviouslyQueued); if (inlined && !(item.IsDelegateInvoked || item.IsCanceled)) { throw new InvalidOperationException("PerlaScheduler_InconsistentStateAfterTryExecuteTaskInline"); } return(inlined); }
private void ExecuteWithThreadLocal(ref PerlaItem currentItemSlot, Thread threadPoolThread) { PerlaItem previousItem = currentItemSlot; try { currentItemSlot = this; try { ExecutionContext ec = CapturedContext; if (ec == null) { InnerInvoke(); } else { if (threadPoolThread == null) { ExecutionContext.Run(ec, s_ecCallback, this); } else { ExecutionContext.Run(ec, s_ecCallback, this); } } } catch (Exception exn) { HandleException(exn); } Finish(true); } finally { currentItemSlot = previousItem; } }
internal void InternalQueueTask(PerlaItem task) { Debug.Assert(task != null); this.QueueTask(task); }
protected internal virtual bool TryDequeue(PerlaItem item) { return(false); }
protected abstract bool TryExecuteTaskInline(PerlaItem item, bool taskWasPreviouslyQueued);
protected internal abstract void QueueTask(PerlaItem item);
protected internal override void QueueTask(PerlaItem item) { m_synchronizationContext.Post(s_postCallback, (object)item); }
internal PerlaExceptionHolder(PerlaItem item) { Debug.Assert(item != null, "Expected a non-null item."); m_item = item; }
protected internal override bool TryDequeue(PerlaItem item) { /* return ThreadPool.TryPopCustomWorkItem(item);*/ return(false); }