Include lock performance (bug #3234)
authorMark Spencer <markster@digium.com>
Fri, 7 Jan 2005 06:14:50 +0000 (06:14 +0000)
committerMark Spencer <markster@digium.com>
Fri, 7 Jan 2005 06:14:50 +0000 (06:14 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@4700 65c4cc65-6c06-0410-ace0-fbb531ad65f3

include/asterisk/astobj.h

index 0f26b2f..0dd70a3 100755 (executable)
@@ -161,6 +161,16 @@ extern "C" {
                ASTOBJ_CONTAINER_UNLOCK(container); \
        } while(0)
 
+#define ASTOBJ_CONTAINER_FIND(container,namestr) \
+       ({ \
+               typeof((container)->head) found = NULL; \
+               ASTOBJ_CONTAINER_TRAVERSE(container, !found, do { \
+                       if (!(strcasecmp(iterator->name, (namestr)))) \
+                               found = ASTOBJ_REF(iterator); \
+               } while (0)); \
+               found; \
+       })
+
 #define ASTOBJ_CONTAINER_FIND_FULL(container,data,field,hashfunc,hashoffset,comparefunc) \
        ({ \
                typeof((container)->head) found = NULL; \
@@ -186,6 +196,25 @@ extern "C" {
                ASTOBJ_CONTAINER_UNLOCK(container); \
        } while(0)
 
+#define ASTOBJ_CONTAINER_FIND_UNLINK(container,namestr) \
+       ({ \
+               typeof((container)->head) found = NULL; \
+               typeof((container)->head) prev = NULL; \
+               ASTOBJ_CONTAINER_TRAVERSE(container, !found, do { \
+                       if (!(strcasecmp(iterator->name, (namestr)))) { \
+                               found = iterator; \
+                               ASTOBJ_CONTAINER_WRLOCK(container); \
+                               if (prev) \
+                                       prev->next[0] = next; \
+                               else \
+                                       (container)->head = next; \
+                               ASTOBJ_CONTAINER_UNLOCK(container); \
+                       } \
+                       prev = iterator; \
+               } while (0)); \
+               found; \
+       })
+
 #define ASTOBJ_CONTAINER_FIND_UNLINK_FULL(container,data,field,hashfunc,hashoffset,comparefunc) \
        ({ \
                typeof((container)->head) found = NULL; \
@@ -252,12 +281,6 @@ extern "C" {
 #define ASTOBJ_CONTAINER_DESTROY(container) \
        ASTOBJ_CONTAINER_DESTROY_FULL(container,1,ASTOBJ_DEFAULT_BUCKETS)
 
-#define ASTOBJ_CONTAINER_FIND(container,namestr) \
-       ASTOBJ_CONTAINER_FIND_FULL(container,namestr,name,ASTOBJ_DEFAULT_HASH,0,strcasecmp)
-
-#define ASTOBJ_CONTAINER_FIND_UNLINK(container,namestr) \
-       ASTOBJ_CONTAINER_FIND_UNLINK_FULL(container,namestr,name,ASTOBJ_DEFAULT_HASH,0,strcasecmp)
-
 #define ASTOBJ_CONTAINER_LINK(container,newobj) \
        ASTOBJ_CONTAINER_LINK_FULL(container,newobj,(newobj)->name,name,ASTOBJ_DEFAULT_HASH,0,strcasecmp)