thread-pool icon indicating copy to clipboard operation
thread-pool copied to clipboard

enqueue_detach a non-void returning function

Open jtd-formlabs opened this issue 1 year ago • 6 comments

Moved the function requirement into a constexpr if statement and std::ignore any return value from a given function. added a super basic test.

jtd-formlabs avatar Jul 02 '24 00:07 jtd-formlabs

Thanks for the PR.

Just curious, but what is the motivating use case for this change?

DeveloperPaul123 avatar Jul 02 '24 03:07 DeveloperPaul123

No problem!

I have an instance where I have a function that takes a fair amount of arguments and returns a value that I don't care about when running asynchronously. Setting up a lambda myself to do this is a bit tedious because then I have to manually handle all of the arguments, so if this library has this change I can just rely on perfect forwarding.

I had a few extra minutes to play around and figured I'd put up the PR for thoughts. No biggie if there are other reasons to restrict this to void returning functions only.

jtd-formlabs avatar Jul 02 '24 11:07 jtd-formlabs

I see, thanks for the break down! I don't think this should be a problem, just want to check for any performance implications but I think it should be ok.

DeveloperPaul123 avatar Jul 02 '24 12:07 DeveloperPaul123

yeah I don't believe this will have any measurable performance impact on existing tests -- I just pushed a code bubble down into the function body but it's still compile time evaluated.

jtd-formlabs avatar Jul 02 '24 12:07 jtd-formlabs

I think I'd be ok merging this. Could you address the formatting issues? The CI uses clang-format 18.1.3

DeveloperPaul123 avatar Jul 02 '24 15:07 DeveloperPaul123

yep I'll take care of that later today

jtd-formlabs avatar Jul 02 '24 16:07 jtd-formlabs

Thanks!

DeveloperPaul123 avatar Jul 02 '24 21:07 DeveloperPaul123