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

[RFC] New module for thread synchronization. #89

Closed
wants to merge 2 commits into from

Conversation

planetis-m
Copy link
Contributor

@planetis-m planetis-m commented Apr 23, 2021

This gathers some useful thread synchronization primitives gathered from various sources. It includes:

  • SpinLock implementation, based on https://rigtorp.se/spinlock/
  • Barrier, translated from glibc source
  • Semaphore from nim's own sources
  • RwMonitor (also known as RwLock) from blog post
  • Arc pointer type, it's the same as fusion/smartptrs SharedPtr
  • Once @xflywind's patch to the stdlib

Todo:

  • A test file for each
  • Documentation and examples

Missing:
ConstPtr, should it be added?
Any kind of queue, for example rust provides a MPSC queue in its library. I have a Nim port of a SPMC queue based on Chase-Lev algorithm. I think it's better to have separate modules for queues.

@juancarlospaco
Copy link
Contributor

Maybe each thing in a separate file can look more simple and easy to understand (?), but everything else looks really good.

@planetis-m
Copy link
Contributor Author

planetis-m commented May 2, 2021

For now I updated my module because its easier. I still think this belongs to the stdlib. If anyone wants to help by reviewing or contributing code, tests and benchmarks is very welcome to do so. Please leave this PR open for more visibility.

@planetis-m planetis-m closed this Jul 5, 2021
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.

2 participants