Skip to content

Commit

Permalink
[core] Move ToTimeoutPoint to util.cc (#49560)
Browse files Browse the repository at this point in the history
Signed-off-by: kaihsun <[email protected]>
  • Loading branch information
kevin85421 authored Jan 3, 2025
1 parent 277b9e9 commit 526fad6
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 22 deletions.
17 changes: 0 additions & 17 deletions src/ray/core_worker/experimental_mutable_object_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -471,18 +471,6 @@ Status MutableObjectManager::SetErrorAll() {
return ret;
}

std::optional<std::chrono::steady_clock::time_point> MutableObjectManager::ToTimeoutPoint(
int64_t timeout_ms) {
std::optional<std::chrono::steady_clock::time_point> timeout_point;
if (timeout_ms == -1) {
return timeout_point;
}
auto now = std::chrono::steady_clock::now();
auto timeout_duration = std::chrono::milliseconds(timeout_ms);
timeout_point.emplace(now + timeout_duration);
return timeout_point;
}

Status MutableObjectManager::GetChannelStatus(const ObjectID &object_id, bool is_reader) {
Channel *channel = GetChannel(object_id);
if (channel == nullptr) {
Expand Down Expand Up @@ -576,11 +564,6 @@ Status MutableObjectManager::SetErrorAll() {
return Status::NotImplemented("Not supported on Windows.");
}

std::optional<std::chrono::steady_clock::time_point> MutableObjectManager::ToTimeoutPoint(
int64_t timeout_ms) {
return std::nullopt;
}

Status MutableObjectManager::GetChannelStatus(const ObjectID &object_id, bool is_reader) {
return Status::NotImplemented("Not supported on Windows.");
}
Expand Down
5 changes: 0 additions & 5 deletions src/ray/core_worker/experimental_mutable_object_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,11 +227,6 @@ class MutableObjectManager : public std::enable_shared_from_this<MutableObjectMa
Channel *GetChannel(const ObjectID &object_id) ABSL_LOCKS_EXCLUDED(channel_lock_);

private:
/// Converts a timeout in milliseconds to a timeout point.
/// \param[in] timeout_ms The timeout in milliseconds.
/// \return The timeout point, or std::nullopt if timeout_ms is -1.
std::optional<std::chrono::steady_clock::time_point> ToTimeoutPoint(int64_t timeout_ms);

// Returns the plasma object header for the object.
PlasmaObjectHeader *GetHeader(const ObjectID &object_id);

Expand Down
11 changes: 11 additions & 0 deletions src/ray/util/util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -440,4 +440,15 @@ std::string FormatFloat(float value, int32_t precision) {
return ss.str();
}

std::optional<std::chrono::steady_clock::time_point> ToTimeoutPoint(int64_t timeout_ms) {
std::optional<std::chrono::steady_clock::time_point> timeout_point;
if (timeout_ms == -1) {
return timeout_point;
}
auto now = std::chrono::steady_clock::now();
auto timeout_duration = std::chrono::milliseconds(timeout_ms);
timeout_point.emplace(now + timeout_duration);
return timeout_point;
}

} // namespace ray
6 changes: 6 additions & 0 deletions src/ray/util/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include <iterator>
#include <memory>
#include <mutex>
#include <optional>
#include <random>
#include <sstream>
#include <string>
Expand Down Expand Up @@ -378,4 +379,9 @@ void QuickExit();
/// \return the foramtted value
std::string FormatFloat(float value, int32_t precision);

/// Converts a timeout in milliseconds to a timeout point.
/// \param[in] timeout_ms The timeout in milliseconds.
/// \return The timeout point, or std::nullopt if timeout_ms is -1.
std::optional<std::chrono::steady_clock::time_point> ToTimeoutPoint(int64_t timeout_ms);

} // namespace ray

0 comments on commit 526fad6

Please sign in to comment.