Insert a pointer to an open file object into the file cache with the filename as the cache key. Returns a handle to the inserted entry. The handle always contains an open file.
| 127 | // Returns a handle to the inserted entry. The handle always contains an open |
| 128 | // file. |
| 129 | ScopedOpenedDescriptor<FileType> InsertIntoCache(void* file_ptr) const { |
| 130 | // The allocated charge is always one byte. This is incorrect with respect |
| 131 | // to memory tracking, but it's necessary if the cache capacity is to be |
| 132 | // equivalent to the max number of fds. |
| 133 | auto pending(cache()->Allocate(filename(), sizeof(file_ptr), 1)); |
| 134 | CHECK(pending); |
| 135 | memcpy(cache()->MutableValue(&pending), &file_ptr, sizeof(file_ptr)); |
| 136 | return ScopedOpenedDescriptor<FileType>( |
| 137 | this, cache()->Insert(std::move(pending), |
| 138 | file_cache_->eviction_cb_.get())); |
| 139 | } |
| 140 | |
| 141 | // Retrieves a pointer to an open file object from the file cache with the |
| 142 | // filename as the cache key. |
no test coverage detected