Skip to content

Conversation

@fxn
Copy link
Contributor

@fxn fxn commented Jan 11, 2019

This patch is actually a question.

The reason Hash can be chosen in MRI as implementation for Concurrent::Hash cannot be that the interpreter does not run threads in parallel, because if you issue a delete call, say, and there is a context switch, even if only one thread runs at a time, the internal state of the hash could be left inconsistent.

What we need for Hash to work, really, is that their functions are atomic in practice.

Not realeasing the GIL while C runs is something that I've heard, but I don't really know if my proposal is correct. Someone knowledgeable should validate it.

I could do the same in Concurrent::Array and others if there are more.

@pitr-ch
Copy link
Member

pitr-ch commented Feb 3, 2019

@fxn yeah, your new comment is more accurate and correct. Thanks. Please update it for array as well.

@pitr-ch pitr-ch added enhancement Adding features, adding tests, improving documentation. in progress labels Feb 3, 2019
@fxn fxn changed the title Fixes a code comment in Concurrent::Hash Fixes a code comment in Concurrent::{Hash,Array} Feb 3, 2019
@fxn
Copy link
Contributor Author

fxn commented Feb 3, 2019

Excellent, I have updated the analogous comment in Concurrent::Array.

I have noticed Concurrent::Set has a similar comment, but Set is partially written in Ruby. Therefore, I am not really sure Concurrent::Set is actually thread-safe in CRuby. (But if that is correct, would probably be out of the scope of this patch anyway.)

Copy link
Contributor

@thedarkone thedarkone left a comment

Choose a reason for hiding this comment

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

@fxn's wording is better.

Copy link
Member

@pitr-ch pitr-ch left a comment

Choose a reason for hiding this comment

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

Thanks!

@pitr-ch pitr-ch merged commit f126463 into ruby-concurrency:master Feb 7, 2019
@ghost ghost removed the in progress label Feb 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Adding features, adding tests, improving documentation.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants