Skip to content

Modify AppDirsFactory.getInstance() to return the singleton instance#118

Merged
harawata merged 1 commit into
masterfrom
117-singleton
Feb 26, 2025
Merged

Modify AppDirsFactory.getInstance() to return the singleton instance#118
harawata merged 1 commit into
masterfrom
117-singleton

Conversation

@harawata

Copy link
Copy Markdown
Owner

I couldn't verify whether WindowsAppDirs is thread-safe or not.
It looks reasonable to assume it is, but if the assumption is wrong, we might have to revert this.

This won't break any existing solutions, but I plan to bump the minor version to 1.4.0 just in case.

Should fix #117

Cc: @koppor

I am not entirely sure if `WindowsAppDirs` is thread-safe or not.
It looks reasonable to assume it is, but if the assumption is wrong, I might have to revert this.
@harawata harawata self-assigned this Feb 26, 2025
}

/** Singleton instance holder. */
private static class Holder {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@harawata harawata Feb 26, 2025

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

I am not sure if we can apply the enum singleton here.
If you have a clear idea, could you show me the essential part? (or send a PR if you prefer)

@koppor

koppor commented Feb 26, 2025

Copy link
Copy Markdown

I couldn't verify whether WindowsAppDirs is thread-safe or not. It looks reasonable to assume it is, but if the assumption is wrong, we might have to revert this.

If it is not thread safe, one could make use of synchronized maybe?

This won't break any existing solutions, but I plan to bump the minor version to 1.4.0 just in case.

Yeah, sounds good!

Thank you for the quick action taken!

@harawata harawata merged commit 392e453 into master Feb 26, 2025
@harawata harawata modified the milestone: 1.4.0 Feb 26, 2025
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.

getInstance should re-use an existing instance

2 participants