Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 10:10:12

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 
0016 namespace gloo {
0017 namespace rendezvous {
0018 
0019 class FileStore : public Store {
0020  public:
0021   explicit FileStore(const std::string& path);
0022   virtual ~FileStore() {}
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   std::vector<std::string> getAllKeyFilePaths();
0038 
0039  protected:
0040   std::string basePath_;
0041 
0042   std::string realPath(const std::string& path);
0043 
0044   std::string tmpPath(const std::string& name);
0045 
0046   std::string objectPath(const std::string& name);
0047 
0048   bool check(const std::vector<std::string>& keys);
0049 
0050   std::vector<std::string> keyFilePaths_;
0051 };
0052 
0053 } // namespace rendezvous
0054 } // namespace gloo