Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions include/cachinglayer/lrucache/DList.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ class DList : public std::enable_shared_from_this<DList> {
IsEmpty() const;

// Reserve loading resource with timeout, called before loading a cell.
// When timeout > 0, the request will fail after the specified duration.
// When timeout == 0, the request will wait indefinitely (no timeout).
// Note: timeout=0 requests use time_point::max() as their deadline, which
// means they sort after all finite-deadline requests in the waiting queue.
folly::SemiFuture<bool>
ReserveLoadingResourceWithTimeout(const ResourceUsage& size, std::chrono::milliseconds timeout,
OpContext* ctx = nullptr);
Expand Down
3 changes: 2 additions & 1 deletion src/cachinglayer/lrucache/DList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ DList::ReserveLoadingResourceWithTimeout(const ResourceUsage& original_size, std
// If immediate reservation fails, add to waiting queue
std::unique_lock<std::mutex> lock(list_mtx_);

auto deadline = std::chrono::steady_clock::now() + timeout;
auto deadline =
timeout.count() > 0 ? std::chrono::steady_clock::now() + timeout : std::chrono::steady_clock::time_point::max();
auto [promise, future] = folly::makePromiseContract<bool>();

uint64_t request_id = next_request_id_.fetch_add(1);
Expand Down
Loading