Skip to content

Make work items void and parameterless making the work queue api simpler#154

Merged
EmJayGee merged 1 commit intomainfrom
micgrier/detachable-work-items
Jan 17, 2026
Merged

Make work items void and parameterless making the work queue api simpler#154
EmJayGee merged 1 commit intomainfrom
micgrier/detachable-work-items

Conversation

@EmJayGee
Copy link
Copy Markdown
Collaborator

The work queue api supported passing a general list of parameters to a lambda or other callable and also the callable having a return value that at least in theory could be gotten although the api didn't expose the mechanism to get to it.

This revision simplifies the api to be only void() so that the enqueue() api can be augmented with the ability to enrichen the queued item with a string description which can be composed via the formatting library.

Perhaps this is overkill and an m::wsstring or the like should have been the 2nd parameter, It would be nice to have an experimental language feature to have like parameter groups (like the format string and the parameter lists) for vformat() calls together and be able to specify and move them as a group. Maybe the next next language.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR simplifies the work queue API by restricting work items to parameterless void() callables, removing the previous support for arbitrary parameters and return values. The simplification enables adding optional string descriptions to enqueued work items via a format string API.

Changes:

  • Removed template-based runnable_work_item class that supported arbitrary parameters and return values
  • Updated enqueue() to accept only void() callables with optional format string descriptions
  • Moved work_item implementation from header to separate source files and changed namespace from work_queue_impl to work_queue_impl
  • Changed description() return type from std::wstring to m::not_null<m::cwzstring> for efficiency

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
test_work_queue.cpp Updated test cases to use new simplified enqueue API and added test for description feature
work_queue_base.h Updated do_enqueue signature to accept packaged_task and description, removed do_wait_until
work_queue_base.cpp Consolidated work item creation into do_enqueue, removed do_wait_until implementation
work_item.h New file defining work_item class in work_queue_impl namespace
work_item.cpp New file implementing work_item methods moved from header
work_queue.h Removed inline runnable_work_item template class, simplified enqueue API, added description formatting
thread_description.h Added constructor accepting cwzstring for compatibility

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/libraries/threadpool/test/test_work_queue.cpp Outdated
Comment thread src/libraries/threadpool/test/test_work_queue.cpp Outdated
Comment thread src/libraries/threadpool/include/m/threadpool/work_queue.h Outdated
@EmJayGee EmJayGee force-pushed the micgrier/detachable-work-items branch 2 times, most recently from 85bc567 to 22040b2 Compare January 17, 2026 05:41
@EmJayGee EmJayGee requested a review from Copilot January 17, 2026 18:02
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/libraries/threadpool/src/work_item.h Outdated
Comment thread src/libraries/threadpool/src/work_item.cpp Outdated
Comment thread src/libraries/threadpool/include/m/threadpool/work_queue.h
@EmJayGee EmJayGee force-pushed the micgrier/detachable-work-items branch from 22040b2 to 0f8aa15 Compare January 17, 2026 20:26
@EmJayGee EmJayGee merged commit c38d9e8 into main Jan 17, 2026
5 checks passed
@EmJayGee EmJayGee deleted the micgrier/detachable-work-items branch January 17, 2026 20:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants