dennis / slipstream

ISC License
5 stars 0 forks source link

Simplify instance tracking #110

Closed dennis closed 3 years ago

dennis commented 3 years ago

Initially, I was using LuaReferences (the objects that Slipstream handles to the Lua code) to keep track of usage. So if all references to a certain Instance were freed, it would stop the instance. And starting it again, if needed, when new ones were created.

This didnt really worked that well, as for some reason, NLua kept it's reference to the Reference object longer than expected.

This PR simplifies how this work: 1) We're are not shutting instances down when not used. it can be implemented as each instance know how many is using it. 2) Instead of tracking LuaReferences, each Lua script sends a InternalAddDependency when a new instance is used, and upon exit it will send a InternalRemoveDependency.