Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
kingcrimsontianyu committed Jan 26, 2025
1 parent 1676a41 commit 3f78be3
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions cpp/include/kvikio/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,18 +152,16 @@ std::tuple<void*, std::size_t, std::size_t> get_alloc_info(const void* devPtr,
template <typename T>
bool is_future_done(const T& future)
{
// If the future does not refer to a valid shared state.
if (!future.valid()) { return true; }

// If the future is returned from std::async(std::launch::deferred), its
// state is always deferred until wait() is called.
// If the future is returned from std::async(std::launch::deferred, ...), its state is always
// deferred until wait() is called to make it ready.
if (future.wait_for(std::chrono::seconds(0)) == std::future_status::deferred) {
future.wait();
return true;
}

// If the future is returned from std::async(std::launch:async).
return future.wait_for(std::chrono::seconds(0)) != std::future_status::timeout;
return future.wait_for(std::chrono::seconds(0)) == std::future_status::ready;
}

#ifdef KVIKIO_CUDA_FOUND
Expand Down

0 comments on commit 3f78be3

Please sign in to comment.