Skip to content
This repository has been archived by the owner on Aug 31, 2019. It is now read-only.

[WIP] Handles #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

[WIP] Handles #5

wants to merge 1 commit into from

Conversation

jedediah
Copy link
Member

This is a generalization of the idea behind some recent SportBukkit changes

Objects that are prone to leakage, such as World, Entity, etc, can provide a Handle to themselves, a lightweight object that knows how to retrieve the object, but does not hold a strong reference to it. Trying to access the object beyond its natural lifespan throws an exception. Handles to the same object compare equal to each other, and this can be determined without dereferencing the object. A handle can also provide a dynamic proxy for the object that delegates method calls through the handle.

Objects can provide Handles through the Handleable interface. This uses a WeakReference by default, but this has the limitation that any leak of the object prevents the release of all Handles. Things like World or Entity would implement Handles using their UUID.

This needs a bit more work, and some implementation in SportBukkit and BungeeCord.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant