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

Make MMapFactory and VMapFactory singleton creation thread safe indep… #19070

Closed
wants to merge 10 commits into from

Conversation

chaodhib
Copy link
Contributor

@chaodhib chaodhib commented Feb 7, 2017

Changes proposed:

  • Make MMapFactory and VMapFactory singleton creation thread safe independently of creation context. Does not solve any issue. Just cleaning up some old code.

Target branch(es): 3.3.5/master

  • 3.3.5
  • master

Issues addressed: Does not solve any issue.

Tests performed: Build. Server starts correctly.

g_MMapManager = NULL;
}
static MMapManager g_MMapManager;
return &g_MMapManager;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

new line xd

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oups. fixed

@jackpoz
Copy link
Contributor

jackpoz commented Feb 8, 2017

Tests performed: Build. Server starts correctly.

could you please test tools too ?

@joschiwald
Copy link
Contributor

why not removing these factorys and declare the singletons how we do it everywhere?

@chaodhib
Copy link
Contributor Author

chaodhib commented Feb 15, 2017

@joschiwald Factory pattern is used. It was useful in the past (for VMAP). So I guess it won't hurt to keep it just in case it could be useful again in the future.

@jackpoz Done. Starts correctly too.

@joschiwald
Copy link
Contributor

joschiwald commented Feb 15, 2017 via email

@Shauren
Copy link
Member

Shauren commented Feb 15, 2017

I don't see any benefit in this change - it actually has negative consequences (exceptionally rare). You see, current approach assumes that you can have different IVMapManager interface implementations (the last time we gained new one was with vmaps overhaul few years ago). If you are going to remove it then also remove the interface, drop 2 from VMapManager2 class name etc...
All that for no gain and only cluttering history

@chaodhib
Copy link
Contributor Author

chaodhib commented Feb 15, 2017

I don't see any benefit in this change

Are you talking about the use of the factory pattern or this PR?

This PR's gain is just to clean up the code as we go. In the long run, this approach helps to keep the code concise & clean wherever possible.

And ok, sure. I will remove the factories, the interface and rename VMapManager2 to VMapManager then.

@Shauren
Copy link
Member

Shauren commented Feb 15, 2017

And then you step right into the other point I made - cluttering history with a change that brings absolutely nothing

@chaodhib
Copy link
Contributor Author

chaodhib commented Feb 16, 2017

I'm not going to argue the benefits of code refactoring with you again, Shauren. Because yes, I remember arguing with you about the same thing in the past. I already spend enough time harassing people about code quality at my day job . I'm not going to do it when I code for fun.

I've done the changes. The fact is: It's 200 less LOC and 5 unneeded files removed. Builds, runs and shutdown correctly (server & tools).

PS: Since you know C++ better than me, what would had been more constructive is access whether or not the "negative consequences" that you mentioned (= change of the order of the destructor calls which may or may not cause issues) are real.

@Shauren
Copy link
Member

Shauren commented Feb 16, 2017

You should damn well know what my opinion on refactoring only PRs is. Just NO.

@jackpoz
Copy link
Contributor

jackpoz commented Feb 16, 2017

none thinks about my CLI branch :(

btw https://travis-ci.org/TrinityCore/TrinityCore/builds/202077771#L867

@chaodhib
Copy link
Contributor Author

@jackpoz your CLI branch?

{
static VMapManager gVMapManager;
return &gVMapManager;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

VMapManager& VMapManager::Instance()
{
    static VMapManager instance;
    return instance;
}

for more consistence

Copy link
Contributor Author

@chaodhib chaodhib Feb 16, 2017

Choose a reason for hiding this comment

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

createOrGetXMapManager() returns a pointer. not a reference. To change that would require to modify the code of every calls to this method. I would like to avoid that.

Unless you are talking about renaming the method?

@chaodhib
Copy link
Contributor Author

chaodhib commented May 2, 2017

I'm dropping this. This is minor change and since there is opposition, I don't want to spend more time on this.

@chaodhib chaodhib closed this May 2, 2017
@chaodhib chaodhib deleted the singleton_static branch May 2, 2017 22:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants