Beispiel #1
0
            public bool releaseHead()
            {
                if (_queue.isEmpty())
                {
                    return(false);
                }

                ResourceNode node = _queue.poll();

                GameObject obj = node.obj;

                node.obj = null;

                GameObject.Destroy(obj);

                --_parent.num;

                //直接-1
                if (_refCount == 0 && _queue.isEmpty())
                {
                    LoadControl.unloadOne(id);
                }

                return(true);
            }
Beispiel #2
0
        /**
         * 构造失效节点: 一个节点的失效节点所代表的字符串是该节点所表示它的字符串的最大 部分前缀
         */
        private void buildFailNode()
        {
            // 以下构造失效节点
            SQueue <DFANode> queues = new SQueue <DFANode>();

            dfaEntrance.failNode = dfaEntrance;          //

            foreach (DFANode v in dfaEntrance.dfaTransition)
            {
                v.level = 1;
                queues.offer(v);
                v.failNode = dfaEntrance;              // 失效节点指向状态机初始状态
            }
            ;

            DFANode curNode  = null;
            DFANode failNode = null;

            while (!queues.isEmpty())
            {
                curNode  = queues.poll();             // 该节点的失效节点已计算
                failNode = curNode.failNode;


                foreach (var kv in curNode.dfaTransition.entrySet())
                {
                    char    k = kv.key;
                    DFANode v = kv.value;

                    // 如果父节点的失效节点中有条相同的出边,那么失效节点就是父节点的失效节点
                    while (failNode != dfaEntrance && !failNode.dfaTransition.contains(k))
                    {
                        failNode = failNode.failNode;
                    }

                    v.failNode = failNode.dfaTransition.get(k);

                    if (v.failNode == null)
                    {
                        v.failNode = dfaEntrance;
                    }

                    v.level = curNode.level + 1;
                    queues.offer(v);                    // 计算下一层
                }
            }
        }
Beispiel #3
0
        private static void runLoadOne(int index)
        {
            if (_loadQueue.isEmpty())
            {
                _loadings[index] = null;
                _loaders[index].unload();

                //完毕
                if (_loadingNum == 0)
                {
                    downloadOver();
                }

                return;
            }

            _loadingNum++;
            _loaders[index].loadResource((_loadings[index] = _loadQueue.poll()).name);
        }
Beispiel #4
0
        /** 执行一次 */
        public void runOnce()
        {
            lock (_queue)
            {
                Action <T> consumer = _consumer;
                SQueue <T> queue    = _queue;

                if (!queue.isEmpty())
                {
                    for (int i = queue.size() - 1; i >= 0; --i)
                    {
                        try
                        {
                            consumer(queue.poll());
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(e);
                            throw;
                        }
                    }
                }
            }
        }