Instances become relinquished when the object they wrap has its ownership transferred to a C++ unique_ptr. Unlike ready instances, they can't be validly accessed (because the C++ object might have been destroyed without our knowledge). Unlike non-ready instances, they can't be validly constructed (because the C++ object might still be within its lifetime). They need a new state. This PR handles them by expanding the previous nb_inst::ready flag into a two-bit field nb_inst::state. Due to a careful choice of which number represents which state, this should have negligible overhead.
Instances become relinquished when the object they wrap has its ownership transferred to a C++
unique_ptr
. Unlike ready instances, they can't be validly accessed (because the C++ object might have been destroyed without our knowledge). Unlike non-ready instances, they can't be validly constructed (because the C++ object might still be within its lifetime). They need a new state. This PR handles them by expanding the previousnb_inst::ready
flag into a two-bit fieldnb_inst::state
. Due to a careful choice of which number represents which state, this should have negligible overhead.Fixes #550.