express: invert return value of unref_if_one()

This is more consistent with how the return value of unref() works.  Someone might otherwise trip over this.
This commit is contained in:
rdb 2020-03-14 14:59:20 +01:00
parent 32a9ea2cef
commit 1b67931f16
4 changed files with 5 additions and 5 deletions

View File

@ -321,7 +321,7 @@ ref_if_nonzero() const {
* Atomically decreases the reference count of this object if it is one.
* Do not use this. This exists only to implement a special case with the
* state cache.
* @return true if the reference count was decremented to zero.
* @return false if the reference count was decremented to zero.
*/
INLINE bool ReferenceCount::
unref_if_one() const {
@ -329,7 +329,7 @@ unref_if_one() const {
nassertr(test_ref_count_integrity(), 0);
nassertr(_ref_count > 0, 0);
#endif
return (AtomicAdjust::compare_and_exchange(_ref_count, 1, 0) == 1);
return (AtomicAdjust::compare_and_exchange(_ref_count, 1, 0) != 1);
}
/**

View File

@ -215,7 +215,7 @@ garbage_collect() {
do {
RenderAttrib *attrib = (RenderAttrib *)_attribs->get_key(si);
if (attrib->unref_if_one()) {
if (!attrib->unref_if_one()) {
// This attrib has recently been unreffed to 1 (the one we added when
// we stored it in the cache). Now it's time to delete it. This is
// safe, because we're holding the _attribs_lock, so it's not possible

View File

@ -934,7 +934,7 @@ garbage_collect() {
}
}
if (state->unref_if_one()) {
if (!state->unref_if_one()) {
// This state has recently been unreffed to 1 (the one we added when
// we stored it in the cache). Now it's time to delete it. This is
// safe, because we're holding the _states_lock, so it's not possible

View File

@ -1204,7 +1204,7 @@ garbage_collect() {
}
}
if (state->unref_if_one()) {
if (!state->unref_if_one()) {
// This state has recently been unreffed to 1 (the one we added when
// we stored it in the cache). Now it's time to delete it. This is
// safe, because we're holding the _states_lock, so it's not possible