예제 #1
0
        public MyPage GetWritablePage(long pageNumber)
        {
            int position = _current;

            int itemsLeft = _cache.Length;

            while (itemsLeft > 0)
            {
                int i = position % _cache.Length;

                // If the page number is equal to the page number we are looking for (therefore it's valid)
                // Will not fail at PageNumber=0 because the accesor will handle that.
                if (_cache[i].PageNumber != pageNumber)
                {
                    // we continue.
                    itemsLeft--;
                    position++;

                    continue;
                }

                if (!_cache[i].IsWritable)
                {
                    _cache[i] = new PageHandlePtrV1(LowLevelTransactionStub.ModifyPage(pageNumber), true);
                }

                return(_cache[i].Value);
            }

            _current         = (_current + 1) % _cache.Length;
            _cache[_current] = new PageHandlePtrV1(LowLevelTransactionStub.ModifyPage(pageNumber), true);
            return(_cache[_current].Value);
        }
예제 #2
0
 public void Reset(long pageNumber)
 {
     for (int i = 0; i < _cache.Length; i++)
     {
         if (_cache[i].PageNumber == pageNumber)
         {
             _cache[i] = new PageHandlePtrV1();
             return;
         }
     }
 }