Add some extra warnings about the reference cycle dangers of `RegistryKey`

This commit is contained in:
kyren 2018-02-11 06:37:51 -05:00
parent b123eb087d
commit fd0e31c6ea
1 changed files with 5 additions and 0 deletions

View File

@ -23,6 +23,11 @@ pub struct LightUserData(pub *mut c_void);
/// reference to a parent `Lua` instance, and thus is managed differently. Though it is more
/// difficult to use than the normal handle types, it is Send + Sync + 'static, which means that it
/// can be used in many situations where it would be impossible to store a regular handle value.
///
/// Be warned, If you place this into Lua via a `UserData` type, it is *very easy* to accidentally
/// cause reference cycles that the Lua garbage collector cannot resolve. Instead of placing a
/// `RegistryKey` into a `UserData` type, prefer instead to use `UserData::set_user_value` /
/// `UserData::get_user_value`.
pub struct RegistryKey {
pub(crate) registry_id: c_int,
pub(crate) unref_list: Arc<Mutex<Option<Vec<c_int>>>>,