1 | #include <torch/csrc/distributed/c10d/Store.hpp> |
2 | |
3 | namespace c10d { |
4 | |
5 | constexpr std::chrono::milliseconds Store::kDefaultTimeout; |
6 | constexpr std::chrono::milliseconds Store::kNoTimeout; |
7 | |
8 | // Define destructor symbol for abstract base class. |
9 | Store::~Store() = default; |
10 | |
11 | const std::chrono::milliseconds& Store::getTimeout() const noexcept { |
12 | return timeout_; |
13 | } |
14 | |
15 | // Set timeout function |
16 | void Store::setTimeout(const std::chrono::milliseconds& timeout) { |
17 | timeout_ = timeout; |
18 | } |
19 | |
20 | void Store::set(const std::string& key, const std::string& value) { |
21 | set(key, std::vector<uint8_t>(value.begin(), value.end())); |
22 | } |
23 | |
24 | std::string Store::compareSet( |
25 | const std::string& key, |
26 | const std::string& currentValue, |
27 | const std::string& newValue) { |
28 | auto value = compareSet( |
29 | key, |
30 | std::vector<uint8_t>(currentValue.begin(), currentValue.end()), |
31 | std::vector<uint8_t>(newValue.begin(), newValue.end())); |
32 | return std::string(value.begin(), value.end()); |
33 | } |
34 | |
35 | std::string Store::get_to_str(const std::string& key) { |
36 | auto value = get(key); |
37 | return std::string(value.begin(), value.end()); |
38 | } |
39 | |
40 | } // namespace c10d |
41 | |