lidavidm commented on a change in pull request #9620:
URL: https://github.com/apache/arrow/pull/9620#discussion_r621217516
##########
File path: cpp/src/arrow/io/caching.cc
##########
@@ -150,11 +153,44 @@ struct ReadRangeCache::Impl {
entries = std::move(new_entries);
}
}
+
+ virtual std::unique_lock<std::mutex> TakeGuard() {
+ return std::unique_lock<std::mutex>();
+ }
+
+ virtual Future<std::shared_ptr<Buffer>> GetFuture(RangeCacheEntry* entry) {
+ return entry->future;
+ }
+
+ virtual RangeCacheEntry Cache(const ReadRange& range) {
+ return {range, file->ReadAsync(ctx, range.offset, range.length)};
+ }
+};
+
+struct ReadRangeCache::LazyImpl : public ReadRangeCache::Impl {
+ std::mutex entry_mutex;
Review comment:
Yes, it's to avoid two threads trying to find-or-create `entry->future`.
The lock isn't acquired in `GetFuture` to avoid constantly locking/unlocking. I
think what I'll do is move the implementations of the methods to the Impl, then
have LazyImpl acquire the lock and defer to the superclass, while having
ReadRangeCache defer essentially everything to Impl.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]