Exemplo n.º 1
0
 public ObjectCacheBase()
 {
     Key = NextKey;
     // 构造的时候,会放进缓存先。所以,构造的时刻就是 释放的时刻
     IsReleased        = true;
     ReleasedTimePoint = TimeUtils.GetTimeStampSeconds();
 }
Exemplo n.º 2
0
 public BTTimerTask(float interval, AbstractCallback callback)
 {
     mCallback       = callback;
     mCurrentSeconds = TimeUtils.GetTimeStampSeconds();
     mInterval       = interval;
     mNextSeconds    = mCurrentSeconds + mInterval;
     isStop          = true;
 }
Exemplo n.º 3
0
 private void Start()
 {
     if (isStop)
     {
         isStop          = false;
         mCurrentSeconds = TimeUtils.GetTimeStampSeconds();
         mNextSeconds    = mCurrentSeconds + mInterval;
     }
 }
Exemplo n.º 4
0
 // 这个只能通过 ObjectPools.Instance.Release --> ObjectPool.Release -> Release 过来
 public void Released()
 {
     if (!IsReleased)
     {
         Clear();
         ReleasedTimePoint = TimeUtils.GetTimeStampSeconds();// Time.realtimeSinceStartup;
         IsReleased        = true;
     }
 }
Exemplo n.º 5
0
 public bool Process <T>(T obj)
 {
     Start();
     if (TimeUtils.GetTimeStampSeconds() > mNextSeconds)
     {
         if (mCallback != null)
         {
             mCallback.Run();
         }
         Stop();
         return(true);
     }
     return(false);
 }
Exemplo n.º 6
0
 public bool IsExpired(float life)
 {
     return(TimeUtils.GetTimeStampSeconds() - ReleasedTimePoint >= life);
 }