Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make AsyncThreadTimedJoin available on other platforms. #1011

Merged
merged 1 commit into from
Nov 12, 2021

Conversation

zrax
Copy link
Member

@zrax zrax commented Nov 11, 2021

On Linux, this uses pthread_timedjoin_np(). For other OSes (not Windows or Linux), we just fall back to a blocking join :/

On Linux, this uses pthread_timedjoin_np().  For other OSes (not Windows
or Linux), we just fall back to a blocking join :/
@zrax zrax merged commit 0f05536 into H-uru:master Nov 12, 2021
@zrax zrax deleted the pthread_timedjoin branch November 12, 2021 00:04
if (rc == WAIT_TIMEOUT)
LogMsg(kLogDebug, "Thread did not terminate after {} ms", timeoutMs);
thread.detach();
#elif defined(HS_BUILD_FOR_LINUX)
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if this should be a cmake check based on the provider of Threads::Threads. Doesn't pthread exist and offer this functionality on BSD?

Copy link
Member Author

@zrax zrax Nov 12, 2021

Choose a reason for hiding this comment

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

pthreads exist on BSD and Darwin, but the pthread_timedjoin_np is a non-portable extension, which AFAIK is Linux-only.

Copy link
Member

Choose a reason for hiding this comment

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

Some BSDs seem to advertise pthread_timedjoin_np in their manpages, but Darwin support is probably more important :/. Example: https://www.freebsd.org/cgi/man.cgi?pthread_join

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, good to know... Perhaps a better way to do this would be to test for the presence of the function. If I don't forget, I'll make a PR in the future to do that

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.

None yet

3 participants