Skip to content

Commit

Permalink
Inline job_list_reset and remove job_list_get_size
Browse files Browse the repository at this point in the history
  • Loading branch information
andreas-el committed Sep 18, 2023
1 parent 878a7a7 commit ecb30e4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 19 deletions.
3 changes: 1 addition & 2 deletions src/clib/lib/include/ert/job_queue/job_list.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ typedef struct job_list_struct job_list_type;

job_list_type *job_list_alloc();
void job_list_free(job_list_type *job_list);
int job_list_get_size(const job_list_type *job_list);
void job_list_add_job(job_list_type *job_list, job_queue_node_type *job_node);
void job_list_reset(job_list_type *job_list);
size_t job_list_get_size(const job_list_type *job_list);
void job_list_get_wrlock(job_list_type *list);
void job_list_get_rdlock(job_list_type *list);
void job_list_unlock(job_list_type *list);
Expand Down
18 changes: 7 additions & 11 deletions src/clib/lib/job_queue/job_list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,20 @@ struct job_list_struct {

job_list_type *job_list_alloc() { return new job_list_type; }

void job_list_reset(job_list_type *job_list) {
for (auto &vec_job : job_list->vec_jobs)
job_queue_node_free(vec_job);
job_list->vec_jobs.clear();
}

int job_list_get_size(const job_list_type *job_list) {
return job_list->vec_jobs.size();
}

void job_list_add_job(job_list_type *job_list, job_queue_node_type *job_node) {
unsigned long queue_index = job_list->vec_jobs.size();
job_queue_node_set_queue_index(job_node, static_cast<int>(queue_index));
job_list->vec_jobs.push_back(job_node);
}

size_t job_list_get_size(const job_list_type *job_list) {
return job_list->vec_jobs.size();
}

void job_list_free(job_list_type *job_list) {
job_list_reset(job_list);
for (auto &vec_job : job_list->vec_jobs)
job_queue_node_free(vec_job);
job_list->vec_jobs.clear();
delete job_list;
}

Expand Down
6 changes: 0 additions & 6 deletions src/clib/old_tests/job_queue/test_job_list.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#include <stdbool.h>
#include <stdlib.h>

#include <ert/job_queue/job_list.hpp>
#include <ert/job_queue/job_node.hpp>
#include <ert/util/test_util.hpp>
Expand All @@ -18,9 +15,6 @@ void test_add_job() {
job_list_add_job(list, node);
test_assert_int_equal(job_list_get_size(list), 1);
test_assert_int_equal(job_queue_node_get_queue_index(node), 0);

job_list_reset(list);
test_assert_int_equal(0, job_list_get_size(list));
job_list_free(list);
}

Expand Down

0 comments on commit ecb30e4

Please sign in to comment.