-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdevice_status_monitor.h
44 lines (33 loc) · 1.35 KB
/
device_status_monitor.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Copyright 2021 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef FEDERATED_DEVICE_STATUS_MONITOR_H_
#define FEDERATED_DEVICE_STATUS_MONITOR_H_
#include <base/sequence_checker.h>
#include <memory>
#include <vector>
#include "federated/training_condition.h"
namespace dbus {
class Bus;
} // namespace dbus
namespace federated {
// Monitors the device status and answers whether a federated computation task
// should start or early stop.
class DeviceStatusMonitor {
public:
explicit DeviceStatusMonitor(
std::vector<std::unique_ptr<TrainingCondition>> training_conditions);
DeviceStatusMonitor(const DeviceStatusMonitor&) = delete;
DeviceStatusMonitor& operator=(const DeviceStatusMonitor&) = delete;
~DeviceStatusMonitor() = default;
// A builder functions that construct DeviceStatusMonitor from dbus
static std::unique_ptr<DeviceStatusMonitor> CreateFromDBus(dbus::Bus* bus);
// Called before training to see if the device is in a good condition, and
// during the training to see if the training should be aborted.
bool TrainingConditionsSatisfied() const;
private:
const std::vector<std::unique_ptr<TrainingCondition>> training_conditions_;
SEQUENCE_CHECKER(sequence_checker_);
};
} // namespace federated
#endif // FEDERATED_DEVICE_STATUS_MONITOR_H_