Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:00:10

0001 /**
0002  * Copyright (c) 2017-present, Facebook, Inc.
0003  * All rights reserved.
0004  *
0005  * This source code is licensed under the BSD-style license found in the
0006  * LICENSE file in the root directory of this source tree.
0007  */
0008 
0009 #pragma once
0010 
0011 #include "gloo/rendezvous/store.h"
0012 
0013 #include <condition_variable>
0014 #include <mutex>
0015 #include <unordered_map>
0016 
0017 namespace gloo {
0018 namespace rendezvous {
0019 
0020 class HashStore : public Store {
0021  public:
0022   virtual ~HashStore() {}
0023 
0024   virtual void set(const std::string& key, const std::vector<char>& data)
0025       override;
0026 
0027   virtual std::vector<char> get(const std::string& key) override;
0028 
0029   virtual void wait(const std::vector<std::string>& keys) override {
0030     wait(keys, Store::kDefaultTimeout);
0031   }
0032 
0033   virtual void wait(
0034       const std::vector<std::string>& keys,
0035       const std::chrono::milliseconds& timeout) override;
0036 
0037  protected:
0038   std::unordered_map<std::string, std::vector<char>> map_;
0039   std::mutex m_;
0040   std::condition_variable cv_;
0041 };
0042 
0043 } // namespace rendezvous
0044 } // namespace gloo