Exemplo n.º 1
0
        public Page GetWritablePage(long pageNumber)
        {
            int position = current;

            int itemsLeft = _cache.Length;

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

                // If the value is not valid or the page number is not equal
                if (!_cache[i].IsValid || _cache[i].PageNumber != pageNumber)
                {
                    // we continue.
                    itemsLeft--;
                    position++;

                    continue;
                }

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

                return(_cache[i].Value);
            }

            current         = (++current) % _cache.Length;
            _cache[current] = new PageHandlePtr(_tx.ModifyPage(pageNumber), true);
            return(_cache[current].Value);
        }
Exemplo n.º 2
0
 public void Reset(long pageNumber)
 {
     for (int i = 0; i < _cache.Length; i++)
     {
         if (_cache[i].IsValid && _cache[i].PageNumber == pageNumber)
         {
             _cache[i] = new PageHandlePtr();
             return;
         }
     }
 }