6 #ifndef BATCHSERVER_HPP_INCLUDE
7 #define BATCHSERVER_HPP_INCLUDE
68 static std::unique_ptr<BatchServer>
make_unique(
int client_pid,
69 const std::vector<geopm_request_s> &signal_config,
70 const std::vector<geopm_request_s> &control_config);
98 "/run/geopm/batch-buffer-";
105 const std::vector<geopm_request_s> &signal_config,
106 const std::vector<geopm_request_s> &control_config);
108 const std::vector<geopm_request_s> &signal_config,
109 const std::vector<geopm_request_s> &control_config,
110 const std::string &signal_shmem_key,
111 const std::string &control_shmem_key,
113 std::shared_ptr<BatchStatus> batch_status,
114 std::shared_ptr<POSIXSignal> posix_signal,
115 std::shared_ptr<SharedMemory> signal_shmem,
116 std::shared_ptr<SharedMemory> control_shmem,
130 std::function<
void(
void)> run);
135 void push_requests(
void);
136 void read_and_update(
void);
137 void update_and_write(
void);
138 void check_invalid_signal(
void);
139 void check_return(
int ret,
const std::string &func_name)
const;
140 char read_message(
void);
141 void write_message(
char message);
142 void event_loop(
void);
144 const int m_client_pid;
145 const std::string m_server_key;
146 const std::vector<geopm_request_s> m_signal_config;
147 const std::vector<geopm_request_s> m_control_config;
148 const std::string m_signal_shmem_key;
149 const std::string m_control_shmem_key;
151 std::shared_ptr<SharedMemory> m_signal_shmem;
152 std::shared_ptr<SharedMemory> m_control_shmem;
153 std::shared_ptr<BatchStatus> m_batch_status;
154 std::shared_ptr<POSIXSignal> m_posix_signal;
157 bool m_is_client_attached;
158 bool m_is_client_waiting;
161 std::vector<int> m_signal_handle;
164 std::vector<int> m_control_handle;
Definition: BatchServer.hpp:26
static std::unique_ptr< BatchServer > make_unique(int client_pid, const std::vector< geopm_request_s > &signal_config, const std::vector< geopm_request_s > &control_config)
Supports the D-Bus interface for starting a batch server.
Definition: BatchServer.cpp:59
static std::string get_control_shmem_key(const std::string &server_key)
Definition: BatchServer.cpp:73
virtual void stop_batch(void)=0
Supports the D-Bus interface for stopping a batch server.
virtual std::string server_key(void) const =0
static std::string get_signal_shmem_key(const std::string &server_key)
Definition: BatchServer.cpp:67
static constexpr const char * M_SHMEM_PREFIX
Definition: BatchServer.hpp:97
BatchServer()=default
Interface called by geopmd to create the server for batch commands.
virtual int server_pid(void) const =0
virtual bool is_active(void)=0
Returns true if the batch server is running.
virtual ~BatchServer()=default
Definition: BatchServer.hpp:102
void parent_register_handler(void)
Definition: BatchServer.cpp:402
void child_register_handler(void)
Definition: BatchServer.cpp:391
bool is_active(void) override
Returns true if the batch server is running.
Definition: BatchServer.cpp:304
virtual ~BatchServerImp()
Definition: BatchServer.cpp:152
BatchServerImp & operator=(const BatchServerImp &other)=delete
void stop_batch(void) override
Supports the D-Bus interface for stopping a batch server.
Definition: BatchServer.cpp:184
void run_batch(void)
Definition: BatchServer.cpp:246
BatchServerImp(const BatchServerImp &other)=delete
int server_pid(void) const override
Definition: BatchServer.cpp:174
std::string server_key(void) const override
Definition: BatchServer.cpp:179
int fork_with_setup(std::function< char(void)> setup, std::function< void(void)> run)
Fork a process that runs two functions and block until the first function completes.
Definition: BatchServer.cpp:413
BatchServerImp(int client_pid, const std::vector< geopm_request_s > &signal_config, const std::vector< geopm_request_s > &control_config)
Definition: BatchServer.cpp:79
void create_shmem(void)
Definition: BatchServer.cpp:370
Definition: geopm_pio.h:387