added index to thor

This commit is contained in:
Garry Boyer
2007-08-20 23:00:31 +00:00
parent e9a99591b4
commit 2f8cd39ff7
6 changed files with 35 additions and 17 deletions
+12 -1
View File
@@ -258,22 +258,33 @@ typename CacheArray<T>::Element* CacheArray<T>::HandleCacheMiss_(
// unlocked item -- the most likely case is that the first item in the
// fifo is non-negative (i.e. it exists) and it's most likely not locked
for (;;) {
fifo_index_ = (fifo_index_+1) & FIFO_MASK;
if (unlikely(fifo_index_ == 0)) {
fifo_index_ = FIFO_SIZE;
}
fifo_index_--;
victim = fifo_[fifo_index_];
if (unlikely(victim < 0)) {
break;
}
victim_metadata = adjusted_metadatas_ + victim;
if (unlikely(victim_metadata->lock_count != 0)) {
// the block was locked
continue;
}
DEBUG_ASSERT(victim_metadata->data != NULL);
if (BlockDevice::can_write(mode_)) {
cache_->StopWrite(victim);
} else {
cache_->StopRead(victim);
}
victim_metadata->data = NULL;
break;
}