From f631c9bcbb63002f76785479acf0d60f6b98b197 Mon Sep 17 00:00:00 2001 From: Andreas Eknes Lie Date: Wed, 20 Sep 2023 10:14:38 +0200 Subject: [PATCH] Combine alloc and set_driver functions --- src/clib/lib/include/ert/job_queue/job_queue.hpp | 4 +--- src/clib/lib/job_queue/job_queue.cpp | 13 ++----------- .../old_tests/job_queue/test_job_queue_driver.cpp | 5 +---- 3 files changed, 4 insertions(+), 18 deletions(-) diff --git a/src/clib/lib/include/ert/job_queue/job_queue.hpp b/src/clib/lib/include/ert/job_queue/job_queue.hpp index f5ba0bf7941..57142ff8b5d 100644 --- a/src/clib/lib/include/ert/job_queue/job_queue.hpp +++ b/src/clib/lib/include/ert/job_queue/job_queue.hpp @@ -8,9 +8,7 @@ #include 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); diff --git a/src/clib/lib/job_queue/job_queue.cpp b/src/clib/lib/job_queue/job_queue.cpp index 2ce5d6a2148..a9256ce3ba6 100644 --- a/src/clib/lib/job_queue/job_queue.cpp +++ b/src/clib/lib/job_queue/job_queue.cpp @@ -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) { diff --git a/src/clib/old_tests/job_queue/test_job_queue_driver.cpp b/src/clib/old_tests/job_queue/test_job_queue_driver.cpp index faad47ac342..1bf4ec5a1d9 100644 --- a/src/clib/old_tests/job_queue/test_job_queue_driver.cpp +++ b/src/clib/old_tests/job_queue/test_job_queue_driver.cpp @@ -11,11 +11,8 @@ #include 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); }