Skip to content

RefBase classes refactored to use smart pointers#1682

Open
marauder2k7 wants to merge 1 commit intoTorqueGameEngines:developmentfrom
marauder2k9-torque:RefBase-refactor
Open

RefBase classes refactored to use smart pointers#1682
marauder2k7 wants to merge 1 commit intoTorqueGameEngines:developmentfrom
marauder2k9-torque:RefBase-refactor

Conversation

@marauder2k7
Copy link
Contributor

WeakRefBase acts as the base class for almost all EngineObjects but because it used a hard ref counted value it was not thread safe and in turn made all engine subclasses susceptible to race conditions. In an effort to reduce this the class is now driven by a smart shared_ptr.

We use new throughout the engine so the actual shared_ptr logic had to be abstracted away to a weakcontrolblock class. Once the weakrefbase is destructed the control blocks object iss nulled out. Then the shared_ptr as free'd. Any weak ptrs pointing to this object are then free'd automatically. The only class that does its own refcounting is now the StrongRefBase but this should be easily fixed with using the base's shared_ptr ref counting instead. StrongRefBase has to call destroySelf.

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.

1 participant