Skip to content

Commit

Permalink
Fix duration handling in compressed proof timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
haorldbchi committed Aug 17, 2023
1 parent 10c8583 commit e65f0b2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/prover_disk.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,17 +183,17 @@ class ContextQueue {
GreenReaperContext* pop() {
std::unique_lock<std::mutex> lock(mutex);

std::chrono::duration<double> wait_time = std::chrono::seconds(context_queue_timeout);
std::chrono::seconds wait_time = std::chrono::seconds(context_queue_timeout);

while (queue.empty() && wait_time.count() > 0) {
auto before_wait = std::chrono::steady_clock::now();
const auto before_wait = std::chrono::steady_clock::now();

if (condition.wait_for(lock, wait_time) == std::cv_status::timeout) {
break;
}

auto elapsed = std::chrono::duration_cast<std::chrono::duration<double>>(std::chrono::steady_clock::now() - before_wait);
wait_time -= elapsed;
const auto elapsed = std::chrono::duration_cast<std::chrono::seconds>(std::chrono::steady_clock::now() - before_wait);
wait_time -= std::min(elapsed, wait_time);
}

if (queue.empty()) {
Expand Down

0 comments on commit e65f0b2

Please sign in to comment.