Skip to content

Commit

Permalink
Combine alloc and set_driver functions
Browse files Browse the repository at this point in the history
  • Loading branch information
andreas-el committed Sep 21, 2023
1 parent c2e72d4 commit 9e77268
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 18 deletions.
4 changes: 1 addition & 3 deletions src/clib/lib/include/ert/job_queue/job_queue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
#include <ert/job_queue/queue_driver.hpp>

typedef struct job_queue_struct job_queue_type;
extern "C" void job_queue_set_driver(job_queue_type *queue,
queue_driver_type *driver);
extern "C" job_queue_type *job_queue_alloc();
extern "C" job_queue_type *job_queue_alloc(queue_driver_type *driver);
extern "C" void job_queue_free(job_queue_type *);
extern "C" PY_USED int job_queue_add_job_node(job_queue_type *queue,
job_queue_node_type *node);
Expand Down
13 changes: 2 additions & 11 deletions src/clib/lib/job_queue/job_queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,12 @@ struct job_queue_struct {
queue_driver_type *driver = nullptr;
};

/**
Observe that the job_queue returned by this function is NOT ready
for use; a driver must be set explicitly with a call to
job_queue_set_driver() first.
*/
job_queue_type *job_queue_alloc() {
job_queue_type *job_queue_alloc(queue_driver_type *driver) {
auto queue = new job_queue_type;
queue->driver = NULL;
queue->job_list = job_list_alloc();
queue->status = job_queue_status_alloc();
return queue;
}

void job_queue_set_driver(job_queue_type *queue, queue_driver_type *driver) {
queue->driver = driver;
return queue;
}

void job_queue_free(job_queue_type *queue) {
Expand Down
5 changes: 1 addition & 4 deletions src/clib/old_tests/job_queue/test_job_queue_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,8 @@
#include <ert/job_queue/torque_driver.hpp>

void job_queue_set_driver_(job_driver_type driver_type) {
job_queue_type *queue = job_queue_alloc();
queue_driver_type *driver = queue_driver_alloc(driver_type);

job_queue_set_driver(queue, driver);

job_queue_type *queue = job_queue_alloc(driver);
job_queue_free(queue);
queue_driver_free(driver);
}
Expand Down

0 comments on commit 9e77268

Please sign in to comment.