Skip to content

Add libdispatch based NSOperationQueue implementation#602

Merged
rfm merged 8 commits into
gnustep:masterfrom
HendrikHuebner:dispatchQueues
May 5, 2026
Merged

Add libdispatch based NSOperationQueue implementation#602
rfm merged 8 commits into
gnustep:masterfrom
HendrikHuebner:dispatchQueues

Conversation

@HendrikHuebner

Copy link
Copy Markdown
Contributor

This PR adds a new implementation for NSOperationQueue, which uses libdispatch instead of manually spawning threads.

The internal queue implementation is split into two classes: GSDispatchOperationQueue and GSThreadOperationQueue. If libdispatch is available, the dispatch implementation is chosen, otherwise we fall back to the old implementation. The logic for the thread implementation remains mostly unchanged, except for the structural change of moving most of the implementation to another class. I also fixed a bug here: If thread creation throws, we did not decrement the thread count afterwards.

Additionally, this PR adds the underlyingQueue property setter and getter, which is only enabled for libdispatch based implementations. See Apple docs for reference.

@HendrikHuebner HendrikHuebner requested a review from rfm as a code owner April 28, 2026 11:07
@HendrikHuebner

Copy link
Copy Markdown
Contributor Author

Hm I can't reproduce the build failure locally, will try again later.

@rfm rfm left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks. Generally I want to remove dependencies on libdispatch (because it is an extra dependency which has caused portability problems, particularly with bugs in implementations on less commonly used platforms), but your code seems quite cleanly structured and unlikely to make things worse. Probably we are best off relying on a configure-time command line option to disable use of libdispatch even if it seems to be available (to handle platforms where it is buggy or when people simply want to minimise external libraries), and your code is consistent with that configure-time selection.

@rfm rfm merged commit d3594a5 into gnustep:master May 5, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants