Skip to content
This repository has been archived by the owner on Jun 12, 2024. It is now read-only.

threads: sx_signal seems to work differently on different platforms #26

Open
mbullington opened this issue Sep 17, 2022 · 0 comments
Open

Comments

@mbullington
Copy link

Hello! I recently decided to integrate sx into a project to use it for threading / job allocation.

When converting from the largely Win32-esque threading API (the project is a fork of id Tech 4), it seemed like sx_signal worked differently than I'd expected, so I wanted to start a ticket with some of the issues I encountered & if my local fork might be a good fit. mbullington@d881665

Largely I made it mirror Win32 Events more closely, in that it's a switch that gets "flipped" on and waits for listeners.

  • If there are already listeners we do a pthread_cond_broadcast & reset, otherwise we store the value for the next waiter.
  • Separate from these changes (but included in the Win32 API) I added a manual_reset, where the signal won't unflip upon a waiter, but instead needs to manually be reset with the sx_signal_reset_if_manual method.
  • Funny enough I actually removed the old Win32 API from this implementation, as it looks like there was compile-time branching that only ran it for Windows XP (< 6) and older. I figured by now we'd be onto Vista 😆 , and this is the only place in the codebase that had this branching.

If this isn't too opinionated—or you happen to agree—happy to open a PR. Thanks! 😄

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant