| 84 | } |
| 85 | |
| 86 | bool SsdCache::startWrite() { |
| 87 | if (isShutdown_) { |
| 88 | return false; |
| 89 | } |
| 90 | if (writesInProgress_.fetch_add(numShards_) == 0) { |
| 91 | // No write was pending, so now all shards are counted as writing. |
| 92 | return true; |
| 93 | } |
| 94 | // There were writes in progress, so compensate for the increment. |
| 95 | writesInProgress_.fetch_sub(numShards_); |
| 96 | return false; |
| 97 | } |
| 98 | |
| 99 | void SsdCache::write(std::vector<CachePin> pins) { |
| 100 | BOLT_CHECK_LE(numShards_, writesInProgress_); |
no outgoing calls