-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Add channels example #8611
Add channels example #8611
Conversation
Added an example that shows how to use channels in a typical multithreaded scenario.
This is just my second PR for Nim, so let me know if anything isn't quite right. The example aims to be general but useful by explaining what I think most people might often do with |
could that code block be turned into a |
@timotheecour, can Many other modules have module level examples in a comment. Do they not use |
This example mixes channels with |
Would it be better to use pure threads, or single threading instead? |
Better show how to use plain threads with these channels. |
just filed:
IMO it'd be higher priority to fix this, so that you can add your example in top-level |
it now works in devel |
@timotheecour I have a question about the Git workflow here. My fork is quite old and doesn't have that fix yet. I assume I need to sync the fork. Will doing so introduce an unwanted merge commit, or is that okay? Sorry, I'm a bit new to working on large projects :) |
we really want to avoid merge commits, as discussed in another issue. Just do: |
No progress, the example still uses the threadpool. |
This PR revives nim-lang#8611 since the channels module still does not have an example of usage. I attempted to fix the outstanding issue that caused the previous PR to be closed, namely implementing the example on top of threads instead of threadpool. I also added an additional example of using sharedAlloc0 to create channel pointers based on the discussion in nim-lang#4748. Please let me know if there is anything that needs to be changed!
Added an example that shows
how to use channels in a typical
multithreaded scenario.