public DefaultWorkflowSchedulerService(NameValueCollection parameters)
 {
     this.timerQueue = new KeyedPriorityQueue<Guid, CallbackInfo, DateTime>();
     if (parameters == null)
     {
         throw new ArgumentNullException("parameters");
     }
     this.maxSimultaneousWorkflows = DefaultThreadCount;
     foreach (string str in parameters.Keys)
     {
         if (str == null)
         {
             throw new ArgumentException(string.Format(Thread.CurrentThread.CurrentCulture, ExecutionStringManager.UnknownConfigurationParameter, new object[] { "null" }));
         }
         string s = parameters[str];
         if (!str.Equals("maxSimultaneousWorkflows", StringComparison.OrdinalIgnoreCase))
         {
             throw new ArgumentException(string.Format(Thread.CurrentThread.CurrentCulture, ExecutionStringManager.UnknownConfigurationParameter, new object[] { str }));
         }
         if (!int.TryParse(s, NumberStyles.Integer, CultureInfo.CurrentCulture, out this.maxSimultaneousWorkflows))
         {
             throw new FormatException("maxSimultaneousWorkflows");
         }
     }
     if (this.maxSimultaneousWorkflows < 1)
     {
         throw new ArgumentOutOfRangeException("maxSimultaneousWorkflows", this.maxSimultaneousWorkflows, string.Empty);
     }
     this.init();
 }
 public ManualWorkflowSchedulerService(NameValueCollection parameters)
 {
     this.pendingScheduleRequests = new KeyedPriorityQueue<Guid, CallbackInfo, DateTime>();
     this.scheduleRequests = new Dictionary<Guid, DefaultWorkflowSchedulerService.WorkItem>();
     this.locker = new object();
     if (parameters == null)
     {
         throw new ArgumentNullException("parameters");
     }
     foreach (string str in parameters.Keys)
     {
         bool flag;
         if (str == null)
         {
             throw new ArgumentException(string.Format(Thread.CurrentThread.CurrentCulture, ExecutionStringManager.UnknownConfigurationParameter, new object[] { "null" }));
         }
         string str2 = parameters[str];
         if (!str.Equals("UseActiveTimers", StringComparison.OrdinalIgnoreCase))
         {
             throw new ArgumentException(string.Format(Thread.CurrentThread.CurrentCulture, ExecutionStringManager.UnknownConfigurationParameter, new object[] { str }));
         }
         if (!bool.TryParse(str2, out flag))
         {
             throw new FormatException("UseActiveTimers");
         }
         if (flag)
         {
             this.timerCallback = new TimerCallback(this.OnTimerCallback);
             this.pendingScheduleRequests.FirstElementChanged += new EventHandler<KeyedPriorityQueueHeadChangedEventArgs<CallbackInfo>>(this.OnFirstElementChanged);
             WorkflowTrace.Host.TraceEvent(TraceEventType.Information, 0, "ManualWorkflowSchedulerService: Started with active timers");
         }
     }
 }
 public DefaultWorkflowSchedulerService(int maxSimultaneousWorkflows)
 {
     this.timerQueue = new KeyedPriorityQueue<Guid, CallbackInfo, DateTime>();
     if (maxSimultaneousWorkflows < 1)
     {
         throw new ArgumentOutOfRangeException("maxSimultaneousWorkflows", maxSimultaneousWorkflows, string.Empty);
     }
     this.maxSimultaneousWorkflows = maxSimultaneousWorkflows;
     this.init();
 }
 public ManualWorkflowSchedulerService(bool useActiveTimers)
 {
     this.pendingScheduleRequests = new KeyedPriorityQueue<Guid, CallbackInfo, DateTime>();
     this.scheduleRequests = new Dictionary<Guid, DefaultWorkflowSchedulerService.WorkItem>();
     this.locker = new object();
     if (useActiveTimers)
     {
         this.timerCallback = new TimerCallback(this.OnTimerCallback);
         this.pendingScheduleRequests.FirstElementChanged += new EventHandler<KeyedPriorityQueueHeadChangedEventArgs<CallbackInfo>>(this.OnFirstElementChanged);
         WorkflowTrace.Host.TraceEvent(TraceEventType.Information, 0, "ManualWorkflowSchedulerService: started with active timers");
     }
 }
예제 #5
0
파일: CTimeSys.cs 프로젝트: yh821/Zombie
    public override void SysInitial()
    {
        m_cheat     = false;
        m_queue     = new KeyedPriorityQueue <uint, AbsTimerData, ulong>();
        m_stopWatch = new Stopwatch();

        System.Timers.Timer t = new System.Timers.Timer(m_deltaSystemTimer);
        t.Elapsed  += Theout; //到达时间的时候执行事件;
        t.AutoReset = true;   //设置是执行一次(false)还是一直执行(true);
        t.Enabled   = true;   //是否执行System.Timers.Timer.Elapsed事件;

        Instance = this;
        InvokeRepeating("Tick", 0f, 0.03f);

        base.SysInitial();
    }
예제 #6
0
 public AStarFast(byte[,] grid)
 {
     if (grid == null)
     {
         throw new Exception("Grid null");
     }
     mGrid  = grid;
     mGridX = (ushort)mGrid.GetLength(0);
     mGridY = (ushort)mGrid.GetLength(1);
     if (!IsPower2(mGridX) || !IsPower2(mGridY))
     {
         throw new Exception("must be power of 2, check size X, Y");
     }
     mGridXMod  = (ushort)(mGridX - 1);
     mGridXLog2 = (ushort)Math.Log(mGridX, 2);
     mGridNode  = new PathNode[mGridX * mGridY];
     mOpenTable = new KeyedPriorityQueue <ushort, ushort, float>();
     _multiple  = 1.0f / mGridX;
 }
        private static void UpdateEdge(HalfEdge edgeToRemove, KeyedPriorityQueue <int, HalfEdge, float> priorityQueue, HashSet <EdgeID> deletedEdgeSet, List <Vector2> pointList)
        {
            HalfEdge left   = GetUndeletedLeft(edgeToRemove, deletedEdgeSet);
            HalfEdge right  = GetUndeletedRight(edgeToRemove, deletedEdgeSet);
            HalfEdge reLeft = RepresentActive(left);

            if (priorityQueue.Contain(reLeft.mKey))
            {
                // Check if this is still removable
                HalfEdge leftOfLeft = GetUndeletedLeft(left.mPartner, deletedEdgeSet);
                if ((leftOfLeft.mPartner != null && (leftOfLeft.mPartner.mKey == right.mKey || leftOfLeft.mPartner.mKey == edgeToRemove.mKey)) ||
                    !GeoPolygonUtils.IsConvex(pointList[edgeToRemove.mIndex], pointList[right.mNext.mIndex], pointList[leftOfLeft.mIndex]))
                {
                    priorityQueue.Remove(reLeft.mKey);
                }
                else
                {
                    // Need to update the priority
                    float pri = GetSmallestAdjacentAngleOnEdge(left, deletedEdgeSet, pointList);
                    priorityQueue.Remove(reLeft.mKey);
                    priorityQueue.Enqueue(reLeft.mKey, reLeft, pri);
                }
            }
            HalfEdge reRight = RepresentActive(right);

            if (priorityQueue.Contain(reRight.mKey))
            {
                HalfEdge rightOfRight = GetUndeletedRight(right, deletedEdgeSet);
                if ((rightOfRight.mPartner != null && (rightOfRight.mPartner.mKey == left.mKey || rightOfRight.mKey == edgeToRemove.mKey)) ||
                    !GeoPolygonUtils.IsConvex(pointList[edgeToRemove.mIndex], pointList[rightOfRight.mNext.mIndex], pointList[left.mIndex]))
                {
                    priorityQueue.Remove(reRight.mKey);
                }
                else
                {
                    priorityQueue.Remove(reRight.mKey);
                    priorityQueue.Enqueue(reRight.mKey, reRight, GetSmallestAdjacentAngleOnEdge(right, deletedEdgeSet, pointList));
                }
            }
        }
        private static List <List <int> > HMDecompose(List <Vector2> vertes, List <int> indices)
        {
            //List<List<Vector2>> triangleDraw = new List<List<Vector2>>();
            //for (int i = 0; i < indices.Count / 3; ++i)
            //{
            //    List<Vector2> tmp = new List<Vector2>();
            //    tmp.Add(vertes[indices[i * 3]]);
            //    tmp.Add(vertes[indices[i * 3 + 1]]);
            //    tmp.Add(vertes[indices[i * 3 + 2]]);
            //    triangleDraw.Add(tmp);
            //}
            //DrawLineUtils.BackPair2[0] = new KeyValuePair<int, System.Drawing.Color>(triangleDraw.Count - 1, DrawLineUtils.BackPair2[0].Value);
            List <HalfEdge> edges = BuilderEdge(indices);
            //foreach (HalfEdge eg in edges)
            //{
            //    List<Vector2> tmp = new List<Vector2>();
            //    tmp.Add(vertes[eg.mIndex]);
            //    tmp.Add(vertes[eg.mNext.mIndex]);
            //    triangleDraw.Add(tmp);
            //}
            //DrawLineUtils.BackPair2[1] = new KeyValuePair<int, System.Drawing.Color>(triangleDraw.Count - 1, DrawLineUtils.BackPair2[1].Value);
            KeyedPriorityQueue <int, HalfEdge, float> remoableEdge = new KeyedPriorityQueue <int, HalfEdge, float>();

            GetRemovableEdgeQueue(vertes, edges, ref remoableEdge);
            //foreach (HalfEdge eg in remoableEdge.Values)
            //{
            //    if (eg.mIndex < eg.mNext.mIndex)
            //    {
            //        List<Vector2> tmp = new List<Vector2>();
            //        tmp.Add(vertes[eg.mIndex]);
            //        tmp.Add(vertes[eg.mNext.mIndex]);
            //        triangleDraw.Add(tmp);
            //    }
            //}
            //DrawLineUtils.BackPair2[2] = new KeyValuePair<int, System.Drawing.Color>(triangleDraw.Count - 1, DrawLineUtils.BackPair2[2].Value);
            //DrawLineUtils.SavePolygonToFile("decompose.bmp", triangleDraw, DrawLineUtils.BackPair2);
            HashSet <EdgeID> st = DeleteEdges(remoableEdge, vertes);

            return(ExtractPolygonList(edges, st));
        }
예제 #9
0
 public void Init()
 {
     this.m_queue           = new KeyedPriorityQueue <int, TimerBase, uint>();
     this.m_iTempFrameCount = 0;
 }
예제 #10
0
 static TimerHeap()
 {
     TimerHeap.QueueLock_  = new object();
     TimerHeap.TimerQueue_ = new KeyedPriorityQueue <uint, AbsTimerData, ulong>();
     TimerHeap.StopWatch_  = new Stopwatch();
 }
예제 #11
0
 static TimerTaskQueue()
 {
     mPriorityQueue = new KeyedPriorityQueue <uint, TimerTask, ulong>();
     mStopWatch     = new Stopwatch();
 }
예제 #12
0
 public TaskPool()
 {
     m_FreeAgents    = new Stack <ITaskAgent <T> >();
     m_WorkingAgents = new LinkedList <ITaskAgent <T> >();
     m_WaitingTasks  = new KeyedPriorityQueue <int, T, int>();
 }
예제 #13
0
 protected TimerBase()
 {
     this.mQueue = new KeyedPriorityQueue <long, TimerData <T>, double>();
 }
예제 #14
0
 public void Init()
 {
     this.m_queue                 = new KeyedPriorityQueue <int, TimerBase, uint>();
     this.m_oStopWatch            = new Stopwatch();
     this.m_fRealTimeSinceStartUp = 0;
 }
예제 #15
0
        public void GenerateDisjktraMatrix(NodeType startNode, float infinite)
        {
            if (mAdjacencyLists.Count == 0)
            {
                return;
            }
            mCostMatrix     = new float[mAdjacencyLists.Count * mAdjacencyLists.Count];
            mLeastNodeArray = new NodeType[mAdjacencyLists.Count];
            //mCostMatrixIndices.Clear();
            //foreach (var key in mAdjacencyLists.Keys)
            //{
            //    mCostMatrixIndices.Add(key);
            //}
            //mCostMatrixIndices.Sort((NodeType node1, NodeType node2) => { return mCompareFunc(node1, node2); }); // 由小到大排序
            for (int i = 0; i < mAdjacencyLists.Count * mAdjacencyLists.Count; ++i)
            {
                mCostMatrix[i] = infinite;
            }
            int adjacentIndex = GetIndexByKey(startNode);

            if (adjacentIndex == -1)
            {
                throw new Exception("-1 null");
            }
            for (int r = 0; r < mAdjacencyLists.Count; ++r)
            {
                mCostMatrix[r * mAdjacencyLists.Count + adjacentIndex] = 0.0f;
            }
            mRootNode = startNode;
            int      row         = 0;
            NodeType currentNode = startNode;
            Dictionary <NodeType, float> adjacencyList;
            float    edgeWeight, adjacentNodeWeight, currentNodeWeight = 0.0f;
            NodeType adjacentKey;
            Dictionary <NodeType, float> openSet = new Dictionary <NodeType, float>();

            while (row < mAdjacencyLists.Count - 1)
            {
                adjacencyList = mAdjacencyLists[currentNode];
                foreach (var v in adjacencyList)
                {
                    edgeWeight         = v.Value;
                    adjacentKey        = v.Key;
                    adjacentIndex      = GetIndexByKey(adjacentKey);
                    adjacentNodeWeight = mCostMatrix[row * mAdjacencyLists.Count + adjacentIndex];
                    if (currentNodeWeight + edgeWeight < adjacentNodeWeight)
                    {
                        // Update the weight for the adjacent node
                        for (int r = row; r < mAdjacencyLists.Count; r++)
                        {
                            mCostMatrix[r * mAdjacencyLists.Count + adjacentIndex] = currentNodeWeight + edgeWeight;
                        }
                        if (!openSet.ContainsKey(adjacentKey))
                        {
                            openSet.Add(adjacentKey, currentNodeWeight + edgeWeight);
                        }
                        else
                        {
                            openSet[adjacentKey] = currentNodeWeight + edgeWeight;
                        }
                    }
                }
                KeyedPriorityQueue <NodeType, NodeType, float> minHeap = new KeyedPriorityQueue <NodeType, NodeType, float>();
                foreach (var open in openSet)
                {
                    minHeap.Enqueue(open.Key, open.Key, open.Value);
                }
                if (minHeap.Count == 0)
                {
                    isValidPath = true;
                    break;
                }
                currentNodeWeight    = minHeap.PeekPriority();
                mLeastNodeArray[row] = minHeap.Dequeue();
                currentNode          = mLeastNodeArray[row];
                openSet.Remove(currentNode);
                row++;
            }
            isValidPath = true;
        }
예제 #16
0
 static TimerHeap()
 {
     mPriorityQueue = new KeyedPriorityQueue <uint, AbstractTimerData, ulong>();
     mStopWatch     = new Stopwatch();
 }
 /// <summary>
 /// 默认构造函数
 /// </summary>
 static TimerManager()
 {
     m_queue     = new KeyedPriorityQueue <uint, AbsTimerData, ulong>();
     m_stopWatch = new Stopwatch();
 }
 public ManualWorkflowSchedulerService()
 {
     this.pendingScheduleRequests = new KeyedPriorityQueue <Guid, CallbackInfo, DateTime>();
     this.scheduleRequests        = new Dictionary <Guid, DefaultWorkflowSchedulerService.WorkItem>();
     this.locker = new object();
 }
예제 #19
0
 static TimerTaskQueue()
 {
     mPriorityQueue = new KeyedPriorityQueue <uint, AbstractTimerData, ulong>();
 }
        private static void GetRemovableEdgeQueue(List <Vector2> vertes, List <HalfEdge> edges, ref KeyedPriorityQueue <int, HalfEdge, float> remoableEdge)
        {
            HashSet <EdgeID> deleteSet = new HashSet <EdgeID>();

            foreach (HalfEdge edge in edges)
            {
                if (edge.mIndex > edge.mNext.mIndex)
                {
                    continue;
                }
                if (IsEdgeRemovable(vertes, edge))
                {
                    remoableEdge.Enqueue(edge.mKey, edge, GetSmallestAdjacentAngleOnEdge(edge, deleteSet, vertes));
                }
            }
        }
예제 #21
0
 private void Swap(int i, int j)
 {
     KeyedPriorityQueue <K, V, P> .HeapNode <K, V, P> heapNode = this.heap.get_Item(i);
     this.heap.set_Item(i, this.heap.get_Item(j));
     this.heap.set_Item(j, heapNode);
 }
예제 #22
0
 /// <summary>
 /// 默认构造函数
 /// </summary>
 static FrameTimerHeap()
 {
     m_queue = new KeyedPriorityQueue <uint, AbsTimerData, ulong>();
 }
 public ManualWorkflowSchedulerService()
 {
     this.pendingScheduleRequests = new KeyedPriorityQueue<Guid, CallbackInfo, DateTime>();
     this.scheduleRequests = new Dictionary<Guid, DefaultWorkflowSchedulerService.WorkItem>();
     this.locker = new object();
 }