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

Blocking Read #1

Closed
phillipCouto opened this issue Jun 3, 2016 · 3 comments
Closed

Blocking Read #1

phillipCouto opened this issue Jun 3, 2016 · 3 comments

Comments

@phillipCouto
Copy link

phillipCouto commented Jun 3, 2016

Great library!!!! Simple yet effecient! I am just curious for the sake of completion why not implement the blocking read the same way you demonstrate it in your example?

I know it may not be ideal but atleast it will be feature complete and you can optimize in the future. Plus it will make the example more concise and easier to follow for new users.

Just a suggestion =)

@jonhoo jonhoo closed this as completed in 79c20a8 Jun 3, 2016
@jonhoo
Copy link
Owner

jonhoo commented Jun 3, 2016

The solution using thread::yield_now isn't great in terms of performance, and it wastes a lot of CPU cycles. I've implemented it properly now, where receiver threads are parked when trying to receive on an empty bus. This comes at a slight cost to writes, as they now need to check whether there are any threads to wake up before they can return.

@phillipCouto
Copy link
Author

Like I said it was just to make the API symmetrical or more complete to the end user and could be optimized later on if time wasn't permitting. Anyway glad to see you were able to put in place a more efficient method to start with =)

Thanks!

@jonhoo
Copy link
Owner

jonhoo commented Jun 3, 2016

Yeah, I got that, I'm just hesitant to put out those kinds of things, because then people will start complaining that it's inefficient :p I'm still not entirely happy with the current solution, because it won't do very well in very high-churn situations. I'd like to adopt something like mvdnes/spin-rs#29 to busy-wait and yield a few times before resorting to a thread park (there are TODOs in the code already), but that's for another day.

jonhoo added a commit that referenced this issue Mar 25, 2023
…odecov-action-3

Bump codecov/codecov-action from 2 to 3
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

No branches or pull requests

2 participants