Repository navigation
[#557] Workers: Use Deque - #565
Merged
Merged
Conversation
jesperpedersen
requested changes
Apr 2, 2025
| #include <pgmoneta.h> | ||
| #include <logging.h> | ||
| #include <workers.h> | ||
| #include <deque.h> |
| w->outcome = true; | ||
|
|
||
| if (queue_init(&w->queue)) | ||
| pgmoneta_deque_create(true, &w->queue); |
|
|
||
| queue_push(&workers->queue, t); | ||
| struct value_config config = {0}; | ||
| config.destroy_data = destroy_data_wrapper; // define the task destroy function of the deque |
|
|
||
| free(t); | ||
| task_wc->function(task_wc); | ||
| // Note: No need to free task_wc here since the deque's value_config.destroy will handle it |
Member
|
If you want to add comments to a code segment then do or |
Contributor
Author
got it, so you mean we should avoid inline comment |
Member
|
squash |
dancingactor
force-pushed
the
test4
branch
2 times, most recently
from
April 2, 2025 18:43
7bfb8cd to
4b9a7c4
Compare
jesperpedersen
requested changes
Apr 2, 2025
| * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| */ | ||
|
|
||
| #include <deque.h> |
Member
There was a problem hiding this comment.
pgmoneta.h is always first
Member
|
Merged. Thanks for your contribution ! |
Contributor
Author
|
@jesperpedersen Thanks so much for your valuable feedback and time! Are there any other issues to contribute? |
Member
|
@dancingactor Take #567 |
This was referenced Apr 14, 2025
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
implement #557
This PR replace the custom queue in
workers.cwith the existing deque indeque.cimplementation.Details
worker_common, instead of being wrapped in a separatestruct task. Since the deque is designed to hold generic values (with cleanup via value_config), storing the complete task in a single structure simplifies both insertion and memory management.struct semaphore* has_tasks;from original queue to workers since deque doesn't have semaphore logic.