update reference_counting decision
## Decision
-TODO @kodebach: update decision as implemented
-
-- add second reference counter to Key
-- One counter is for locking references, the other one for general references. A locking reference automatically locks/unlocks the keyname.
-- introduce reference counter for KeySets (for external keyset references)
-- `keyBorrow` returns an error in case of reference counter overflow
-- use fixed sized types for reference counters
+- add second counter to Key
+- One counter is for references, the other one is for locking the keyname. The keyname is thereby protected with a re-entrant lock.
+- introduce reference counter for KeySets (for external keyset references, e.g. in bindings)
+- limit number of references to `UINT16_MAX - 1` and use `UINT16_MAX` as an error value
+- return error on reference count overflow
+- no error on underflow (decrement when zero), instead stay at zero
+- use fixed sized types (`uint16_t`) for reference counters
- increment/decrement references before/after passing instances to plugins
## Rationale
- Adding a second reference counter to Key and reducing the size of both significantly (`size_t` to `uint16_t`)
actually saves memory (32 vs 64bit on 64-bit machines) compared to the previous solution.
-- The added complexity of maintaining two reference counters is worth the
- tradeoff for the gained functionality.
+- The added complexity of maintaining two reference counters is worth the trade-off for the gained functionality.
## Implications
-Missing:
-
-- C++ API update
-
## Related Decisions
## Notes
+
+Not implemented yet:
+
+- Update bindings to use KeySet reference counter (especially C++)
+- Second counter for automatic keyname (un)locking
