[pulseaudio-discuss] [PATCH RFCv3 26/51] flist: Don't use atomic operations to manipulate ptr, next
Peter Meerwald
pmeerw at pmeerw.net
Tue Nov 4 15:26:21 PST 2014
From: Peter Meerwald <p.meerwald at bct-electronic.com>
---
src/pulsecore/flist.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/src/pulsecore/flist.c b/src/pulsecore/flist.c
index b110e1e..c7b3825 100644
--- a/src/pulsecore/flist.c
+++ b/src/pulsecore/flist.c
@@ -47,8 +47,8 @@
/* Lock free single linked list element. */
struct pa_flist_elem {
- pa_atomic_t next;
- pa_atomic_ptr_t ptr;
+ int next;
+ void *ptr;
};
typedef struct pa_flist_elem pa_flist_elem;
@@ -80,7 +80,7 @@ static pa_flist_elem *stack_pop(pa_flist *flist, pa_atomic_t *list) {
if (idx < 0)
return NULL;
popped = &flist->table[idx & flist->index_mask];
- } while (!pa_atomic_cmpxchg(list, idx, pa_atomic_load(&popped->next)));
+ } while (!pa_atomic_cmpxchg(list, idx, popped->next));
return popped;
}
@@ -97,7 +97,7 @@ static void stack_push(pa_flist *flist, pa_atomic_t *list, pa_flist_elem *new_el
do {
next = pa_atomic_load(list);
- pa_atomic_store(&new_elem->next, next);
+ new_elem->next = next;
} while (!pa_atomic_cmpxchg(list, next, newindex));
}
@@ -138,7 +138,7 @@ void pa_flist_free(pa_flist *l, pa_free_cb_t free_cb) {
if (free_cb) {
pa_flist_elem *elem;
while((elem = stack_pop(l, &l->stored)))
- free_cb(pa_atomic_ptr_load(&elem->ptr));
+ free_cb(elem->ptr);
}
pa_xfree(l->name);
@@ -156,7 +156,7 @@ int pa_flist_push(pa_flist *l, void *p) {
pa_log_debug("%s flist is full (don't worry)", l->name);
return -1;
}
- pa_atomic_ptr_store(&elem->ptr, p);
+ elem->ptr = p;
stack_push(l, &l->stored, elem);
return 0;
@@ -171,7 +171,7 @@ void* pa_flist_pop(pa_flist *l) {
if (elem == NULL)
return NULL;
- ptr = pa_atomic_ptr_load(&elem->ptr);
+ ptr = elem->ptr;
stack_push(l, &l->empty, elem);
--
1.9.1
More information about the pulseaudio-discuss
mailing list