Skip to content

Commit c43ff85

Browse files
committed
Turn anonymous enum to work_queue_category_mode_t
As recommended by compiler warning when testing for spack.
1 parent c34b301 commit c43ff85

File tree

2 files changed

+18
-26
lines changed

2 files changed

+18
-26
lines changed

work_queue/src/work_queue.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ struct work_queue {
183183
time_t resources_last_update_time;
184184
int busy_waiting_flag;
185185

186-
category_mode_t allocation_default_mode;
186+
work_queue_category_mode_t allocation_default_mode;
187187

188188
FILE *logfile;
189189
FILE *transactions_logfile;
@@ -7198,7 +7198,7 @@ void work_queue_specify_category_first_allocation_guess(struct work_queue *q, c
71987198
category_specify_first_allocation_guess(c, rm);
71997199
}
72007200

7201-
int work_queue_specify_category_mode(struct work_queue *q, const char *category, category_mode_t mode) {
7201+
int work_queue_specify_category_mode(struct work_queue *q, const char *category, work_queue_category_mode_t mode) {
72027202

72037203
switch(mode) {
72047204
case CATEGORY_ALLOCATION_MODE_FIXED:
@@ -7217,7 +7217,7 @@ int work_queue_specify_category_mode(struct work_queue *q, const char *category,
72177217
}
72187218
else {
72197219
struct category *c = work_queue_category_lookup_or_create(q, category);
7220-
category_specify_allocation_mode(c, mode);
7220+
category_specify_allocation_mode(c, (category_mode_t) mode);
72217221
write_transaction_category(q, c);
72227222
}
72237223

@@ -7272,7 +7272,7 @@ struct category *work_queue_category_lookup_or_create(struct work_queue *q, cons
72727272

72737273
if(!c->wq_stats) {
72747274
c->wq_stats = calloc(1, sizeof(struct work_queue_stats));
7275-
category_specify_allocation_mode(c, q->allocation_default_mode);
7275+
category_specify_allocation_mode(c, (category_mode_t) q->allocation_default_mode);
72767276
}
72777277

72787278
return c;

work_queue/src/work_queue.h

+14-22
Original file line numberDiff line numberDiff line change
@@ -95,30 +95,22 @@ typedef enum {
9595

9696
/** Here we repeat the category_mode_t declaration but with work_queue names.
9797
* This is needed to generate uniform names in the API and bindings. */
98-
enum {
98+
typedef enum {
99+
/**< When monitoring is disabled, all tasks run as
100+
WORK_QUEUE_ALLOCATION_MODE_FIXED. If monitoring is enabled and resource
101+
exhaustion occurs: */
99102
WORK_QUEUE_ALLOCATION_MODE_FIXED = CATEGORY_ALLOCATION_MODE_FIXED,
103+
/**< If maximum values are specified for cores, memory,
104+
disk or gpus (either a user-label or category-label) and one of those resources
105+
is exceeded, the task fails. Otherwise it is retried until a large enough
106+
worker connects to the manager, using the maximum values specified, and the
107+
maximum values so far seen for resources not specified. */
100108
WORK_QUEUE_ALLOCATION_MODE_MAX = CATEGORY_ALLOCATION_MODE_MAX,
109+
/**< As above, but tasks are tried with an automatically computed first-allocation to minimize resource waste. */
101110
WORK_QUEUE_ALLOCATION_MODE_MIN_WASTE = CATEGORY_ALLOCATION_MODE_MIN_WASTE,
111+
/**< As above, but maximizing throughput. */
102112
WORK_QUEUE_ALLOCATION_MODE_MAX_THROUGHPUT = CATEGORY_ALLOCATION_MODE_MAX_THROUGHPUT
103-
};
104-
105-
// typedef enum {
106-
// /**< When monitoring is disabled, all tasks run as
107-
// WORK_QUEUE_ALLOCATION_MODE_FIXED. If monitoring is enabled and resource
108-
// exhaustion occurs: */
109-
// WORK_QUEUE_ALLOCATION_MODE_FIXED = 0, /**< Task fails. (default) */
110-
// WORK_QUEUE_ALLOCATION_MODE_MAX, /**< If maximum values are specified for cores, memory,
111-
// disk or gpus (either a user-label or category-label) and
112-
// one of those resources is exceeded, the task fails.
113-
// Otherwise it is retried until a large enough worker
114-
// connects to the manager, using the maximum values
115-
// specified, and the maximum values so far seen for
116-
// resources not specified. */
117-
//
118-
// WORK_QUEUE_ALLOCATION_MODE_MIN_WASTE, /**< As above, but tasks are tried with an automatically
119-
// computed first-allocation to minimize resource waste. */
120-
// WORK_QUEUE_ALLOCATION_MODE_MAX_THROUGHPUT /**< As above, but maximizing throughput. */
121-
// } wq_category_mode_t;
113+
} work_queue_category_mode_t;
122114

123115

124116
extern int wq_option_scheduler; /**< Initial setting for algorithm to assign tasks to
@@ -864,10 +856,10 @@ int work_queue_specify_draining_by_hostname(struct work_queue *q, const char *ho
864856
/** Turn on or off first-allocation labeling for a given category. By default, cores, memory, and disk are labeled, and gpus are unlabeled. Turn on/off other specific resources use @ref work_queue_enable_category_resource
865857
@param q A work queue object.
866858
@param category A category name.
867-
@param mode One of @ref category_mode_t.
859+
@param mode One of @ref work_queue_category_mode_t.
868860
@returns 1 if mode is valid, 0 otherwise.
869861
*/
870-
int work_queue_specify_category_mode(struct work_queue *q, const char *category, category_mode_t mode);
862+
int work_queue_specify_category_mode(struct work_queue *q, const char *category, work_queue_category_mode_t mode);
871863

872864
/** Turn on or off first-allocation labeling for a given category and resource. This function should be use to fine-tune the defaults from @ref work_queue_specify_category_mode.
873865
@param q A work queue object.

0 commit comments

Comments
 (0)