Skip to content
Closed
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
22 changes: 15 additions & 7 deletions src/ray/object_manager/object_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,21 @@ ray::Status ObjectManager::Pull(const ObjectID &object_id) {
}

void ObjectManager::SchedulePull(const ObjectID &object_id, int wait_ms) {
pull_requests_[object_id] = std::make_shared<boost::asio::deadline_timer>(
*main_service_, boost::posix_time::milliseconds(wait_ms));
pull_requests_[object_id]->async_wait(
[this, object_id](const boost::system::error_code &error_code) {
pull_requests_.erase(object_id);
RAY_CHECK_OK(PullGetLocations(object_id));
});
auto timer = std::make_shared<boost::asio::deadline_timer>(
*main_service_, boost::posix_time::milliseconds(wait_ms));

{
std::lock_guard<std::mutex> lock(pull_requests_lock_);
pull_requests_[object_id] = timer;
}

timer->async_wait([this, object_id](const boost::system::error_code &error_code) {
{
std::lock_guard<std::mutex> lock(pull_requests_lock_);
pull_requests_.erase(object_id);
}
RAY_CHECK_OK(PullGetLocations(object_id));
});
}

ray::Status ObjectManager::PullGetLocations(const ObjectID &object_id) {
Expand Down
4 changes: 4 additions & 0 deletions src/ray/object_manager/object_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <map>
#include <memory>
#include <thread>
#include <mutex>

#include <boost/asio.hpp>
#include <boost/asio/error.hpp>
Expand Down Expand Up @@ -178,6 +179,9 @@ class ObjectManager {
/// Connection pool for reusing outgoing connections to remote object managers.
ConnectionPool connection_pool_;

/// Lock for pull_requests_
std::mutex pull_requests_lock_;

/// Timeout for failed pull requests.
std::unordered_map<ObjectID, std::shared_ptr<boost::asio::deadline_timer>>
pull_requests_;
Expand Down