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

Weenie caching to fix portals #419

Merged
merged 3 commits into from
Jun 27, 2017
Merged

Weenie caching to fix portals #419

merged 3 commits into from
Jun 27, 2017

Conversation

Mogwai-TheFurry
Copy link
Contributor

No description provided.

…n the object factory, though I highly doubt i fixed the real issue.

public AceObject GetAceObjectByWeenie(uint weenieClassId)
{
if (!_weenieCache.ContainsKey(weenieClassId))
Copy link
Contributor

Choose a reason for hiding this comment

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

This is most likely unsafe. Unless ContainsKey is guaranteed atomic w.r.t. _weenieCache (if Dictionaries are hash maps under the hood its highly unlikely), then this will eventually crash the code. Double-check locking relies on a strictly atomic and ordered pre-check (volatility guarantees ordering).

public AceObject GetObject(uint aceObjectId)
{
// if they're asking for a weenie, just give them the weenie.
if (_weenieCache.ContainsKey(aceObjectId))
Copy link
Contributor

Choose a reason for hiding this comment

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

Also unsafe, unless ContainsKey is atomic w.r.t. _weenieCache.

@Mogwai-TheFurry
Copy link
Contributor Author

switched to a ConcurrentDictionary. blah.

@ddevec ddevec merged commit 8a3574e into ACEmulator:master Jun 27, 2017
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.

2 participants