Example #1
0
        public void Get <T>(Action <T> callback)
        {
            if (mKeyQueue != null)
            {
                mKeyQueue.OnComplete((tmpData) => {
                    T value = GetValue <T>(tmpData);
                    ResetData();
                    callback(value);
                });

                mKeyQueues.Enqueue(mKeyQueue);
                mKeyQueue = null;
                ExecuteKeysQueue();
                return;
            }

            if (callback == null)
            {
                Debug.LogWarning(GetType() + "/Get()/callback is null, Don't return data");
                ResetData();

                return;
            }
            T data = GetValue <T>(mTmpData);

            ResetData();
            callback(data);
        }
Example #2
0
        private bool SetKey <T>(T key)
        {
            if (mData == null || mKeyQueue != null)
            {
                if (mKeyQueue == null)
                {
                    mKeyQueue = new KeyQueue();
                }

                IKey keyData = new Key();
                keyData.Set(key);
                mKeyQueue.Enqueue(keyData);

                return(true);
            }

            return(false);
        }
Example #3
0
        public void Count(Action <int> callback)
        {
            bool isSuccess = SetKey <Action>(() => {
                if (callback != null)
                {
                    callback.Invoke(GetCount());
                }
            });

            if (isSuccess == false)
            {
                if (callback != null)
                {
                    callback.Invoke(GetCount());
                }
            }
            else
            {
                mKeyQueues.Enqueue(mKeyQueue);
                mKeyQueue = null;
            }
        }