[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v7 1/7] qom: apply atomic on object's refcount
From: |
Liu Ping Fan |
Subject: |
[Qemu-devel] [PATCH v7 1/7] qom: apply atomic on object's refcount |
Date: |
Sun, 25 Nov 2012 10:02:58 +0800 |
From: Liu Ping Fan <address@hidden>
Signed-off-by: Liu Ping Fan <address@hidden>
---
qom/object.c | 5 ++---
1 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/qom/object.c b/qom/object.c
index e3e9242..1a697b3 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -600,16 +600,15 @@ GSList *object_class_get_list(const char *implements_type,
void object_ref(Object *obj)
{
- obj->ref++;
+ __sync_fetch_and_add(&obj->ref, 1);
}
void object_unref(Object *obj)
{
g_assert(obj->ref > 0);
- obj->ref--;
/* parent always holds a reference to its children */
- if (obj->ref == 0) {
+ if (__sync_fetch_and_sub(&obj->ref, 1) == 1) {
object_finalize(obj);
}
}
--
1.7.4.4
- [Qemu-devel] [PATCH v7 0/7] push mmio dispatch out of big lock, Liu Ping Fan, 2012/11/24
- [Qemu-devel] [PATCH v7 1/7] qom: apply atomic on object's refcount,
Liu Ping Fan <=
- [Qemu-devel] [PATCH v7 2/7] hotplug: introduce qdev_unplug_complete() to remove device from views, Liu Ping Fan, 2012/11/24
- [Qemu-devel] [PATCH v7 3/7] pci: remove pci device from mem view when unplug, Liu Ping Fan, 2012/11/24
- [Qemu-devel] [PATCH v7 4/7] memory: introduce local lock for address space, Liu Ping Fan, 2012/11/24
- [Qemu-devel] [PATCH v7 5/7] memory: make mmio dispatch able to be out of biglock, Liu Ping Fan, 2012/11/24
- [Qemu-devel] [PATCH v7 6/7] memory: introduce tls context to trace nested mmio request issue, Liu Ping Fan, 2012/11/24
- [Qemu-devel] [PATCH v7 7/7] vcpu: push mmio dispatcher out of big lock, Liu Ping Fan, 2012/11/24