willox / auxtools

Rust library for low-level interfacing with BYOND's virtual machine. Includes a remote debugger for the BYOND DreamMaker language.
MIT License
28 stars 32 forks source link

Weak values #40

Closed MCHSL closed 2 years ago

MCHSL commented 3 years ago

Adds weak values which are weak references to datums. Pass them wherever and then call upgrade() (on the main thread) to retrieve the references value if it hasn't been deleted in the meantime.

Gonna write some tests tomorrow probably.

willox commented 3 years ago

add strong(er) refs too or is making sure Drop doesn't happen outside of the main thread too hard

MCHSL commented 3 years ago

Whoops, that took a while longer than I anticipated. Strong references would be a bit of a pain, we'd have to either define datum/Del which is a massive performance drain, or hook the internal del machinery and work from there.

willox commented 3 years ago

When I say strong-ref I just mean a normal byond reference. It could still turn into null, but will keep the reference count above 0