Skip to content

Conversation

@kyle-singer
Copy link
Collaborator

Replace pthread_t, pthread_create, and pthread_join with the C++ thread implementations.

unsigned int worker_start = 1;
for (unsigned int i = worker_start; i < g->nworkers; i++) {
int status = pthread_join(g->threads[i], nullptr);
if (status != 0)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I would have liked to have kept these cilkrts_bug calls on failed join/create, but exceptions are turned off in the runtime so any exception should result in std::terminate

@neboat neboat merged commit 87aa32f into OpenCilk:dev Dec 19, 2025
3 checks passed
cilkrts_bug(nullptr, "Cilk: thread creation (%u) failed: %s",
worker_start, strerror(status));
}
new (&g->threads[worker_start]) std::thread{
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't the std::thread already constructed by the new [] call?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

new [] would invoke the default constructor, which creates an object that doesn't actually represent a running thread.

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.

3 participants