| 119 | } |
| 120 | |
| 121 | int |
| 122 | PreservationTable::acquire(Dir const &dir, CacheKey const &key) |
| 123 | { |
| 124 | int bucket = dir_evac_bucket(&dir); |
| 125 | if (EvacuationBlock * b{this->find(dir, bucket)}; nullptr != b) { |
| 126 | if (b->readers) { |
| 127 | ++b->readers; |
| 128 | } |
| 129 | return 0; |
| 130 | } |
| 131 | // we don't actually need to preserve this block as it is already in |
| 132 | // memory, but this is easier, and evacuations are rare |
| 133 | EvacuationBlock *b = new_EvacuationBlock(); |
| 134 | b->readers = 1; |
| 135 | b->dir = dir; |
| 136 | b->evac_frags.key = key; |
| 137 | this->evacuate[bucket].push(b); |
| 138 | return 1; |
| 139 | } |
| 140 | |
| 141 | void |
| 142 | PreservationTable::release(Dir const &dir) |
no test coverage detected