diff options
author | Thomas Hellstrom <thellstrom-at-vmware-dot-com> | 2009-03-13 15:47:18 +0100 |
---|---|---|
committer | Thomas Hellstrom <thellstrom-at-vmware-dot-com> | 2009-03-16 11:40:47 +0100 |
commit | cf25ef9072f5290d228a381727c4ff921b0c60d6 (patch) | |
tree | 6e8be9bcf952d395920d742ac3468896c52ffed8 /src/gallium/include | |
parent | fc1ef97c3349588cd33a22dc88ab30b6f701000e (diff) |
gallium: Use struct pipe_atomic for pipe refcounts.
Signed-off-by: Thomas Hellstrom <thellstrom-at-vmware-dot-com>
Diffstat (limited to 'src/gallium/include')
-rw-r--r-- | src/gallium/include/pipe/p_refcnt.h | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/gallium/include/pipe/p_refcnt.h b/src/gallium/include/pipe/p_refcnt.h index 27b4e8fbfed..60844e40a57 100644 --- a/src/gallium/include/pipe/p_refcnt.h +++ b/src/gallium/include/pipe/p_refcnt.h @@ -30,6 +30,7 @@ #include "p_defines.h" +#include "p_atomic.h" #ifdef __cplusplus @@ -39,14 +40,14 @@ extern "C" { struct pipe_reference { - unsigned count; + struct pipe_atomic count; }; static INLINE void pipe_reference_init(struct pipe_reference *reference, unsigned count) { - reference->count = count; + p_atomic_set(&reference->count, count); } @@ -64,13 +65,13 @@ pipe_reference(struct pipe_reference **ptr, struct pipe_reference *reference) /* bump the reference.count first */ if (reference) { - assert(reference->count); - reference->count++; + assert(p_atomic_read(&reference->count) != 0); + p_atomic_inc(&reference->count); } if (*ptr) { - assert((*ptr)->count); - if (--(*ptr)->count == 0) { + assert(p_atomic_read(&(*ptr)->count) != 0); + if (p_atomic_dec_zero(&(*ptr)->count)) { destroy = TRUE; } } |