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

Replace Hashtables with generic ConcurrentDictionaries #218

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

gpetrou
Copy link
Contributor

@gpetrou gpetrou commented Oct 13, 2019

No description provided.

using System.Runtime.InteropServices.ComTypes;
using System.Threading;

namespace Microsoft.Scripting.ComInterop {

public class ComTypeDesc : ComTypeLibMemberDesc {
private string _typeName;
private string _documentation;
//Hashtable is threadsafe for multiple readers single writer.
Copy link
Contributor

Choose a reason for hiding this comment

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

I have not looked at usage. But I assume this comment is here because it's intended to be used in multithreaded scenarios? Dictionary doesn't provide the same thread safety guarantees as Hashtable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I used ConcurrentDictionaries instead. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

Using ConcurrentDictionary seems fine from a thread safety point of view. Hopefully it isn't a perf hit. Just need to find time to look at how these classes are used and will merge it in assuming there are no issues.

@gpetrou gpetrou changed the title Replace Hashtables with generic Dictionaries Replace Hashtables with generic ConcurrentDictionaries Oct 26, 2019
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.

None yet

2 participants