apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mladen Turk <mt...@apache.org>
Subject [PATCH] obtain nidle and acuirable from reslist
Date Wed, 08 Sep 2004 08:27:08 GMT
Hi,
The patch adds two new functions to reslist.
The first one returns the number of idle resources.
The second returns the number of resources that can
be acquired without the need to wait for a free resource.

The purpose for a patch is to remove the nfree calculations
from the new proxy worker/balancer implementation.
It would simplify that a lot cause right now I'm using
the wrapper code that actually counts the number of free
resources in the list, to select the worker that has the
least number of acquired resources, since the apr_reslist
elements are private.



Regards,
MT.


Index: apr_reslist.h
===================================================================
RCS file: /home/cvspublic/apr-util/include/apr_reslist.h,v
retrieving revision 1.9
diff -u -r1.9 apr_reslist.h
--- apr_reslist.h	15 Mar 2004 08:21:26 -0000	1.9
+++ apr_reslist.h	8 Sep 2004 08:16:32 -0000
@@ -131,6 +131,20 @@
  APU_DECLARE(apr_status_t) apr_reslist_invalidate(apr_reslist_t *reslist,
                                                   void *resource);

+/**
+ * Get the number of idle resources.
+ * @param reslist The resource list.
+ * Return a number if idle resources.
+ */
+APU_DECLARE(int) apr_reslist_idle_get(apr_reslist_t *reslist);
+
+/**
+ * Get the number of resources that can be acquired
+ * withouth the need to wait for a free resource.
+ * @param reslist The resource list.
+ * Return a number acquirable resources.
+ */
+APU_DECLARE(int) apr_reslist_acquirable_get(apr_reslist_t *reslist);

  #ifdef __cplusplus
  }

Index: apr_reslist.c
===================================================================
RCS file: /home/cvspublic/apr-util/misc/apr_reslist.c,v
retrieving revision 1.9
diff -u -r1.9 apr_reslist.c
--- apr_reslist.c	15 Mar 2004 08:21:26 -0000	1.9
+++ apr_reslist.c	8 Sep 2004 08:16:11 -0000
@@ -371,4 +371,14 @@
      return ret;
  }

+APU_DECLARE(int) apr_reslist_idle_get(apr_reslist_t *reslist)
+{
+    return reslist->nidle;
+}
+
+APU_DECLARE(int) apr_reslist_acquirable_get(apr_reslist_t *reslist)
+{
+    return (reslist->hmax - reslist->ntotal);
+}
+
  #endif  /* APR_HAS_THREADS */





Mime
View raw message