tangled
alpha
login
or
join now
matrixfurry.com
/
monado
0
fork
atom
The open source OpenXR runtime
0
fork
atom
overview
issues
pulls
pipelines
xrt: Refactor reference functions to be clearer
Jakob Bornecrantz
2 years ago
fffdfa1c
11ae3009
+49
-12
10 changed files
expand all
collapse all
unified
split
src
xrt
auxiliary
tracking
t_tracking.h
util
u_space_overseer.c
u_worker.h
drivers
rift_s
rift_s.c
wmr
wmr_hmd_controller.c
include
xrt
xrt_compositor.h
xrt_defines.h
xrt_frame.h
xrt_space.h
state_trackers
oxr
oxr_objects.h
+1
-1
src/xrt/auxiliary/tracking/t_tracking.h
···
307
*dst = src;
308
309
if (old_dst) {
310
-
if (xrt_reference_dec(&old_dst->reference)) {
311
t_stereo_camera_calibration_destroy(old_dst);
312
}
313
}
···
307
*dst = src;
308
309
if (old_dst) {
310
+
if (xrt_reference_dec_and_is_zero(&old_dst->reference)) {
311
t_stereo_camera_calibration_destroy(old_dst);
312
}
313
}
+1
-1
src/xrt/auxiliary/util/u_space_overseer.c
···
125
*dst = src;
126
127
if (old_dst) {
128
-
if (xrt_reference_dec(&old_dst->base.reference)) {
129
old_dst->base.destroy(&old_dst->base);
130
}
131
}
···
125
*dst = src;
126
127
if (old_dst) {
128
+
if (xrt_reference_dec_and_is_zero(&old_dst->base.reference)) {
129
old_dst->base.destroy(&old_dst->base);
130
}
131
}
+2
-2
src/xrt/auxiliary/util/u_worker.h
···
79
*dst = src;
80
81
if (old_dst) {
82
-
if (xrt_reference_dec(&old_dst->reference)) {
83
u_worker_thread_pool_destroy(old_dst);
84
}
85
}
···
164
*dst = src;
165
166
if (old_dst) {
167
-
if (xrt_reference_dec(&old_dst->reference)) {
168
u_worker_group_destroy(old_dst);
169
}
170
}
···
79
*dst = src;
80
81
if (old_dst) {
82
+
if (xrt_reference_dec_and_is_zero(&old_dst->reference)) {
83
u_worker_thread_pool_destroy(old_dst);
84
}
85
}
···
164
*dst = src;
165
166
if (old_dst) {
167
+
if (xrt_reference_dec_and_is_zero(&old_dst->reference)) {
168
u_worker_group_destroy(old_dst);
169
}
170
}
+1
-1
src/xrt/drivers/rift_s/rift_s.c
···
304
*dst = src;
305
306
if (old_dst) {
307
-
if (xrt_reference_dec(&old_dst->ref)) {
308
rift_s_system_free(old_dst);
309
}
310
}
···
304
*dst = src;
305
306
if (old_dst) {
307
+
if (xrt_reference_dec_and_is_zero(&old_dst->ref)) {
308
rift_s_system_free(old_dst);
309
}
310
}
+1
-1
src/xrt/drivers/wmr/wmr_hmd_controller.c
···
113
{
114
struct wmr_hmd_controller_connection *conn = (struct wmr_hmd_controller_connection *)(base);
115
116
-
if (xrt_reference_dec(&conn->ref)) {
117
wmr_hmd_controller_connection_destroy(conn);
118
} else {
119
os_mutex_lock(&conn->lock);
···
113
{
114
struct wmr_hmd_controller_connection *conn = (struct wmr_hmd_controller_connection *)(base);
115
116
+
if (xrt_reference_dec_and_is_zero(&conn->ref)) {
117
wmr_hmd_controller_connection_destroy(conn);
118
} else {
119
os_mutex_lock(&conn->lock);
+2
-2
src/xrt/include/xrt/xrt_compositor.h
···
498
*dst = src;
499
500
if (old_dst) {
501
-
if (xrt_reference_dec(&old_dst->reference)) {
502
old_dst->destroy(old_dst);
503
}
504
}
···
694
*dst = src;
695
696
if (old_dst) {
697
-
if (xrt_reference_dec(&old_dst->reference)) {
698
old_dst->destroy(old_dst);
699
}
700
}
···
498
*dst = src;
499
500
if (old_dst) {
501
+
if (xrt_reference_dec_and_is_zero(&old_dst->reference)) {
502
old_dst->destroy(old_dst);
503
}
504
}
···
694
*dst = src;
695
696
if (old_dst) {
697
+
if (xrt_reference_dec_and_is_zero(&old_dst->reference)) {
698
old_dst->destroy(old_dst);
699
}
700
}
+38
-1
src/xrt/include/xrt/xrt_defines.h
···
1304
*
1305
*/
1306
0
0
0
0
0
0
1307
static inline void
1308
xrt_reference_inc(struct xrt_reference *xref)
1309
{
1310
xrt_atomic_s32_inc_return(&xref->count);
1311
}
1312
1313
-
static inline bool
0
0
0
0
0
0
1314
xrt_reference_dec(struct xrt_reference *xref)
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1315
{
1316
int32_t count = xrt_atomic_s32_dec_return(&xref->count);
1317
return count == 0;
···
1304
*
1305
*/
1306
1307
+
/*!
1308
+
* Increment the reference, probably want @ref xrt_reference_inc_and_was_zero.
1309
+
*
1310
+
* @memberof xrt_reference
1311
+
* @ingroup xrt_iface
1312
+
*/
1313
static inline void
1314
xrt_reference_inc(struct xrt_reference *xref)
1315
{
1316
xrt_atomic_s32_inc_return(&xref->count);
1317
}
1318
1319
+
/*!
1320
+
* Decrement the reference, probably want @ref xrt_reference_dec_and_is_zero.
1321
+
*
1322
+
* @memberof xrt_reference
1323
+
* @ingroup xrt_iface
1324
+
*/
1325
+
static inline void
1326
xrt_reference_dec(struct xrt_reference *xref)
1327
+
{
1328
+
xrt_atomic_s32_dec_return(&xref->count);
1329
+
}
1330
+
1331
+
/*!
1332
+
* Increment the reference and return true if the value @p was zero.
1333
+
*
1334
+
* @memberof xrt_reference
1335
+
* @ingroup xrt_iface
1336
+
*/
1337
+
XRT_CHECK_RESULT static inline bool
1338
+
xrt_reference_inc_and_was_zero(struct xrt_reference *xref)
1339
+
{
1340
+
int32_t count = xrt_atomic_s32_inc_return(&xref->count);
1341
+
return count == 1;
1342
+
}
1343
+
1344
+
/*!
1345
+
* Decrement the reference and return true if the value is now zero.
1346
+
*
1347
+
* @memberof xrt_reference
1348
+
* @ingroup xrt_iface
1349
+
*/
1350
+
XRT_CHECK_RESULT static inline bool
1351
+
xrt_reference_dec_and_is_zero(struct xrt_reference *xref)
1352
{
1353
int32_t count = xrt_atomic_s32_dec_return(&xref->count);
1354
return count == 0;
+1
-1
src/xrt/include/xrt/xrt_frame.h
···
143
*dst = src;
144
145
if (old_dst) {
146
-
if (xrt_reference_dec(&old_dst->reference)) {
147
old_dst->destroy(old_dst);
148
}
149
}
···
143
*dst = src;
144
145
if (old_dst) {
146
+
if (xrt_reference_dec_and_is_zero(&old_dst->reference)) {
147
old_dst->destroy(old_dst);
148
}
149
}
+1
-1
src/xrt/include/xrt/xrt_space.h
···
66
*dst = src;
67
68
if (old_dst) {
69
-
if (xrt_reference_dec(&old_dst->reference)) {
70
old_dst->destroy(old_dst);
71
}
72
}
···
66
*dst = src;
67
68
if (old_dst) {
69
+
if (xrt_reference_dec_and_is_zero(&old_dst->reference)) {
70
old_dst->destroy(old_dst);
71
}
72
}
+1
-1
src/xrt/state_trackers/oxr/oxr_objects.h
···
2152
static inline void
2153
oxr_refcounted_unref(struct oxr_refcounted *orc)
2154
{
2155
-
if (xrt_reference_dec(&orc->base)) {
2156
orc->destroy(orc);
2157
}
2158
}
···
2152
static inline void
2153
oxr_refcounted_unref(struct oxr_refcounted *orc)
2154
{
2155
+
if (xrt_reference_dec_and_is_zero(&orc->base)) {
2156
orc->destroy(orc);
2157
}
2158
}