Merge pull request #31039 from AdrianVovk/slice-freeze-thaw
Rework slice recursive freeze/thaw
This commit is contained in:
+23
-4
@@ -117,14 +117,33 @@ static const char* const unit_active_state_table[_UNIT_ACTIVE_STATE_MAX] = {
|
||||
DEFINE_STRING_TABLE_LOOKUP(unit_active_state, UnitActiveState);
|
||||
|
||||
static const char* const freezer_state_table[_FREEZER_STATE_MAX] = {
|
||||
[FREEZER_RUNNING] = "running",
|
||||
[FREEZER_FREEZING] = "freezing",
|
||||
[FREEZER_FROZEN] = "frozen",
|
||||
[FREEZER_THAWING] = "thawing",
|
||||
[FREEZER_RUNNING] = "running",
|
||||
[FREEZER_FREEZING] = "freezing",
|
||||
[FREEZER_FREEZING_BY_PARENT] = "freezing-by-parent",
|
||||
[FREEZER_FROZEN] = "frozen",
|
||||
[FREEZER_FROZEN_BY_PARENT] = "frozen-by-parent",
|
||||
[FREEZER_THAWING] = "thawing",
|
||||
};
|
||||
|
||||
DEFINE_STRING_TABLE_LOOKUP(freezer_state, FreezerState);
|
||||
|
||||
/* Maps in-progress freezer states to the corresponding finished state */
|
||||
static const FreezerState freezer_state_finish_table[_FREEZER_STATE_MAX] = {
|
||||
[FREEZER_FREEZING] = FREEZER_FROZEN,
|
||||
[FREEZER_FREEZING_BY_PARENT] = FREEZER_FROZEN_BY_PARENT,
|
||||
[FREEZER_THAWING] = FREEZER_RUNNING,
|
||||
|
||||
/* Finished states trivially map to themselves */
|
||||
[FREEZER_RUNNING] = FREEZER_RUNNING,
|
||||
[FREEZER_FROZEN] = FREEZER_FROZEN,
|
||||
[FREEZER_FROZEN_BY_PARENT] = FREEZER_FROZEN_BY_PARENT,
|
||||
};
|
||||
|
||||
FreezerState freezer_state_finish(FreezerState state) {
|
||||
assert(state >= 0 && state < _FREEZER_STATE_MAX);
|
||||
return freezer_state_finish_table[state];
|
||||
}
|
||||
|
||||
static const char* const unit_marker_table[_UNIT_MARKER_MAX] = {
|
||||
[UNIT_MARKER_NEEDS_RELOAD] = "needs-reload",
|
||||
[UNIT_MARKER_NEEDS_RESTART] = "needs-restart",
|
||||
|
||||
@@ -53,8 +53,10 @@ typedef enum UnitActiveState {
|
||||
|
||||
typedef enum FreezerState {
|
||||
FREEZER_RUNNING,
|
||||
FREEZER_FREEZING,
|
||||
FREEZER_FREEZING, /* freezing due to user request */
|
||||
FREEZER_FROZEN,
|
||||
FREEZER_FREEZING_BY_PARENT, /* freezing as a result of parent slice freezing */
|
||||
FREEZER_FROZEN_BY_PARENT,
|
||||
FREEZER_THAWING,
|
||||
_FREEZER_STATE_MAX,
|
||||
_FREEZER_STATE_INVALID = -EINVAL,
|
||||
@@ -297,6 +299,7 @@ UnitActiveState unit_active_state_from_string(const char *s) _pure_;
|
||||
|
||||
const char *freezer_state_to_string(FreezerState i) _const_;
|
||||
FreezerState freezer_state_from_string(const char *s) _pure_;
|
||||
FreezerState freezer_state_finish(FreezerState i) _const_;
|
||||
|
||||
const char *unit_marker_to_string(UnitMarker m) _const_;
|
||||
UnitMarker unit_marker_from_string(const char *s) _pure_;
|
||||
|
||||
Reference in New Issue
Block a user