Exemple #1
0
 //---------------------------------------------------------------------
 public void addLoadRequest(EntityLoader loader)
 {
     lock (mLockQueEntityLoadRequest)
     {
         mQueEntityLoadRequest.Enqueue(loader);
     }
 }
Exemple #2
0
        //---------------------------------------------------------------------
        void _threadSerializer()
        {
            while (true)
            {
                // 处理Entity Load
                if (!mSignDestroy)
                {
                    EntityLoader loader = null;
                    lock (mLockQueEntityLoadRequest)
                    {
                        if (mQueEntityLoadRequest.Count > 0)
                        {
                            loader = mQueEntityLoadRequest.Dequeue();
                        }
                    }

                    if (loader != null)
                    {
                        loader.handleLoad();

                        lock (mLockQueEntityLoadResponse)
                        {
                            mQueEntityLoadResponse.Enqueue(loader);
                        }
                    }
                }

                // 处理Entity Save
                {
                    EntitySaver saver = null;

                    lock (mLockQueEntitySaveRequest)
                    {
                        if (mQueEntitySaveRequest.Count > 0)
                        {
                            saver = mQueEntitySaveRequest.Dequeue();
                        }
                    }

                    if (saver != null)
                    {
                        saver.handleSave();
                    }

                    if (mSignDestroy)
                    {
                        lock (mLockQueEntitySaveRequest)
                        {
                            if (mQueEntitySaveRequest.Count == 0)
                            {
                                break;
                            }
                        }
                    }
                }

                Thread.Sleep(10);
            }
        }
Exemple #3
0
        //---------------------------------------------------------------------
        public void update(float elapsed_tm)
        {
            bool         done   = false;
            EntityLoader loader = null;
            int          count  = 0;

            while (!done)
            {
                count++;
                if (count > 20)
                {
                    break;
                }

                // GetEntityData
                lock (mLockQueEntityLoadResponse)
                {
                    if (mQueEntityLoadResponse.Count > 0)
                    {
                        loader = mQueEntityLoadResponse.Dequeue();
                    }
                    else
                    {
                        done = true;
                    }
                }

                // CreateEntity
                if (!done)
                {
                    Entity     entity      = null;
                    EntityData entity_data = loader.getEntityData();
                    if (entity_data != null)
                    {
                        entity = mEntityMgr._createEntityImpl(entity_data, loader.getEntityParent(), loader.isRecursive());
                    }
                    loader.onLoadFinished(entity);
                }
            }
        }
Exemple #4
0
 //---------------------------------------------------------------------
 public EntityAsyncStatus asyncLoadCreateEntity(EntityLoader loader)
 {
     mEntitySerializerMgr.addLoadRequest(loader);
     return(loader.getEntityAsyncStatus());
 }