SMT-RAT  24.02
Toolbox for Strategic and Parallel Satisfiability-Modulo-Theories Solving
SSHScheduler.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <benchmax/config.h>
4 
5 #ifdef BENCHMAX_SSH
6 
8 #include <benchmax/logging.h>
9 
10 #include <atomic>
11 
12 namespace benchmax {
13 namespace ssh {
14 
15 class SSHConnection;
16 
17 /// Helper class that schedules jobs among a list of SSH connections.
18 class SSHScheduler {
19 private:
20  /// List of active connections.
21  std::vector<std::unique_ptr<SSHConnection>> mConnections;
22  /// Mutex.
23  std::mutex mMutex;
24  /// Number of current workers.
25  std::size_t mWorkerCount = 0;
26  /// Numbers of running jobs.
27  std::atomic<unsigned> mRunningJobs;
28 
29  /// Return a connection that is not busy.
30  const std::unique_ptr<SSHConnection>& get();
31  /// Create a name for a temporary directory.
32  std::string tmpDirName(const Tool* tool, const fs::path& file) const;
33  /// Create a name for a temporary directory.
34  std::string tmpDirName(const Tool* tool) const;
35 
36  /// Remote tool locations
37  std::map<std::pair<const Tool*, std::string>, std::string> mRemoteToolLocations;
38 public:
39  /// Initializes all SSH connections.
40  SSHScheduler();
41 
42  /// Number of workers.
43  std::size_t workerCount() const {
44  return mWorkerCount;
45  }
46  /// Number of running jobs.
47  std::size_t runningJobs() const {
48  return mRunningJobs;
49  }
50  /// Upload a tool to all remotes.
51  void uploadTool(const Tool* tool);
52  /// Removes all tools from remotes.
53  void cleanupTools();
54  /// Execute a single job.
55  bool executeJob(const Tool* tool, const fs::path& file, Backend* backend);
56 };
57 
58 }
59 }
60 
61 #endif
auto get(const It &it, level)