Skip to content

Commit

Permalink
Use atomics to access objects' user_data.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kerilk committed Aug 24, 2023
1 parent 03d5a7a commit c12cc2a
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/cconfigspace.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,7 @@ ccs_object_set_user_data(ccs_object_t object, void *user_data)
{
CCS_CHECK_BASE_OBJ(object);
_ccs_object_internal_t *obj = (_ccs_object_internal_t *)object;
CCS_RWLOCK_WRLOCK(obj->lock);
obj->user_data = user_data;
CCS_RWLOCK_UNLOCK(obj->lock);
CCS_ATOMIC_STORE(obj->user_data, user_data);
return CCS_RESULT_SUCCESS;
}

Expand All @@ -167,9 +165,7 @@ ccs_object_get_user_data(ccs_object_t object, void **user_data_ret)
CCS_CHECK_BASE_OBJ(object);
CCS_CHECK_PTR(user_data_ret);
_ccs_object_internal_t *obj = (_ccs_object_internal_t *)object;
CCS_RWLOCK_RDLOCK(obj->lock);
*user_data_ret = obj->user_data;
CCS_RWLOCK_UNLOCK(obj->lock);
*user_data_ret = CCS_ATOMIC_LOAD(obj->user_data);
return CCS_RESULT_SUCCESS;
}

Expand Down

0 comments on commit c12cc2a

Please sign in to comment.