You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by da...@apache.org on 2007/07/22 20:55:38 UTC

svn commit: r558527 - in /apr/apr-util/trunk: include/apr_thread_pool.h misc/apr_thread_pool.c

Author: davi
Date: Sun Jul 22 11:55:37 2007
New Revision: 558527

URL: http://svn.apache.org/viewvc?view=rev&rev=558527
Log:
Public APR-UTIL functions are declared with APU_DECLARE(), not APR_DECLARE().
While at it, fix coding style and extern declarations for C++.

PR: 42889

Modified:
    apr/apr-util/trunk/include/apr_thread_pool.h
    apr/apr-util/trunk/misc/apr_thread_pool.c

Modified: apr/apr-util/trunk/include/apr_thread_pool.h
URL: http://svn.apache.org/viewvc/apr/apr-util/trunk/include/apr_thread_pool.h?view=diff&rev=558527&r1=558526&r2=558527
==============================================================================
--- apr/apr-util/trunk/include/apr_thread_pool.h (original)
+++ apr/apr-util/trunk/include/apr_thread_pool.h Sun Jul 22 11:55:37 2007
@@ -16,10 +16,10 @@
  * permissions and limitations under the License.
  */
 
-#ifndef APR_THREAD_POOL_H
-#define APR_THREAD_POOL_H
+#ifndef APU_THREAD_POOL_H
+#define APU_THREAD_POOL_H
 
-#include "apr.h"
+#include "apu.h"
 #include "apr_thread_proc.h"
 
 /**
@@ -40,16 +40,12 @@
  * @remarks There may be the case that a thread pool can use up the maximum
  * number of threads at peak load, but having those threads idle afterwards. A
  * maximum number of idle threads can be set so that extra idling threads will
- * be terminated to save system resrouces. 
+ * be terminated to save system resrouces.
  */
 #if APR_HAS_THREADS
 
 #ifdef __cplusplus
-extern "C"
-{
-#if 0
-};
-#endif
+extern "C" {
 #endif /* __cplusplus */
 
 /**
@@ -73,22 +69,22 @@
  * apr_thread_pool object. The returned value will be NULL if failed to create
  * the thread pool.
  * @param init_threads The number of threads to be created initially, the number
- * will also be used as the initial value for maximum number of idle threads. 
+ * will also be used as the initial value for maximum number of idle threads.
  * @param max_threads The maximum number of threads that can be created
  * @param pool The pool to use
  * @return APR_SUCCESS if the thread pool was created successfully. Otherwise,
  * the error code.
  */
-APR_DECLARE(apr_status_t) apr_thread_pool_create(apr_thread_pool_t ** me,
+APU_DECLARE(apr_status_t) apr_thread_pool_create(apr_thread_pool_t **me,
                                                  apr_size_t init_threads,
                                                  apr_size_t max_threads,
-                                                 apr_pool_t * pool);
+                                                 apr_pool_t *pool);
 
 /**
  * Destroy the thread pool and stop all the threads
  * @return APR_SUCCESS if all threads are stopped.
  */
-APR_DECLARE(apr_status_t) apr_thread_pool_destroy(apr_thread_pool_t * me);
+APU_DECLARE(apr_status_t) apr_thread_pool_destroy(apr_thread_pool_t *me);
 
 /**
  * Schedule a task to the bottom of the tasks of same priority.
@@ -99,7 +95,7 @@
  * @param owner Owner of this task.
  * @return APR_SUCCESS if the task had been scheduled successfully
  */
-APR_DECLARE(apr_status_t) apr_thread_pool_push(apr_thread_pool_t * me,
+APU_DECLARE(apr_status_t) apr_thread_pool_push(apr_thread_pool_t *me,
                                                apr_thread_start_t func,
                                                void *param,
                                                apr_byte_t priority,
@@ -113,7 +109,7 @@
  * @param owner Owner of this task.
  * @return APR_SUCCESS if the task had been scheduled successfully
  */
-APR_DECLARE(apr_status_t) apr_thread_pool_schedule(apr_thread_pool_t * me,
+APU_DECLARE(apr_status_t) apr_thread_pool_schedule(apr_thread_pool_t *me,
                                                    apr_thread_start_t func,
                                                    void *param,
                                                    apr_interval_time_t time,
@@ -128,7 +124,7 @@
  * @param owner Owner of this task.
  * @return APR_SUCCESS if the task had been scheduled successfully
  */
-APR_DECLARE(apr_status_t) apr_thread_pool_top(apr_thread_pool_t * me,
+APU_DECLARE(apr_status_t) apr_thread_pool_top(apr_thread_pool_t *me,
                                               apr_thread_start_t func,
                                               void *param,
                                               apr_byte_t priority,
@@ -143,7 +139,7 @@
  * @note The task function should not be calling cancel, otherwise the function
  * may get stuck forever. The function assert if it detect such a case.
  */
-APR_DECLARE(apr_status_t) apr_thread_pool_tasks_cancel(apr_thread_pool_t * me,
+APU_DECLARE(apr_status_t) apr_thread_pool_tasks_cancel(apr_thread_pool_t *me,
                                                        void *owner);
 
 /**
@@ -151,36 +147,35 @@
  * @param me The thread pool
  * @return Number of tasks in the queue
  */
-APR_DECLARE(apr_size_t) apr_thread_pool_tasks_count(apr_thread_pool_t * me);
+APU_DECLARE(apr_size_t) apr_thread_pool_tasks_count(apr_thread_pool_t *me);
 
 /**
  * Get current number of scheduled tasks waiting in the queue
  * @param me The thread pool
  * @return Number of scheduled tasks in the queue
  */
-APR_DECLARE(apr_size_t)
-    apr_thread_pool_scheduled_tasks_count(apr_thread_pool_t * me);
+APU_DECLARE(apr_size_t) apr_thread_pool_scheduled_tasks_count(apr_thread_pool_t *me);
 
 /**
  * Get current number of threads
  * @param me The thread pool
  * @return Number of total threads
  */
-APR_DECLARE(apr_size_t) apr_thread_pool_threads_count(apr_thread_pool_t * me);
+APU_DECLARE(apr_size_t) apr_thread_pool_threads_count(apr_thread_pool_t *me);
 
 /**
  * Get current number of busy threads
  * @param me The thread pool
  * @return Number of busy threads
  */
-APR_DECLARE(apr_size_t) apr_thread_pool_busy_count(apr_thread_pool_t * me);
+APU_DECLARE(apr_size_t) apr_thread_pool_busy_count(apr_thread_pool_t *me);
 
 /**
  * Get current number of idling thread
  * @param me The thread pool
  * @return Number of idling threads
  */
-APR_DECLARE(apr_size_t) apr_thread_pool_idle_count(apr_thread_pool_t * me);
+APU_DECLARE(apr_size_t) apr_thread_pool_idle_count(apr_thread_pool_t *me);
 
 /**
  * Access function for the maximum number of idling thread. Number of current
@@ -189,7 +184,7 @@
  * @param cnt The number
  * @return The number of threads were stopped.
  */
-APR_DECLARE(apr_size_t) apr_thread_pool_idle_max_set(apr_thread_pool_t * me,
+APU_DECLARE(apr_size_t) apr_thread_pool_idle_max_set(apr_thread_pool_t *me,
                                                      apr_size_t cnt);
 
 /**
@@ -197,15 +192,15 @@
  * @param me The thread pool
  * @return The current maximum number
  */
-APR_DECLARE(apr_size_t) apr_thread_pool_idle_max_get(apr_thread_pool_t * me);
+APU_DECLARE(apr_size_t) apr_thread_pool_idle_max_get(apr_thread_pool_t *me);
 
 /**
- * Access function for the maximum number of thread. 
+ * Access function for the maximum number of thread.
  * @param me The thread pool
  * @param cnt The number
  * @return The original maximum number of threads
  */
-APR_DECLARE(apr_size_t) apr_thread_pool_thread_max_set(apr_thread_pool_t * me,
+APU_DECLARE(apr_size_t) apr_thread_pool_thread_max_set(apr_thread_pool_t *me,
                                                        apr_size_t cnt);
 
 /**
@@ -213,45 +208,38 @@
  * @param me The thread pool
  * @return The current maximum number
  */
-APR_DECLARE(apr_size_t) apr_thread_pool_thread_max_get(apr_thread_pool_t *
-                                                       me);
+APU_DECLARE(apr_size_t) apr_thread_pool_thread_max_get(apr_thread_pool_t *me);
 
 /**
- * Access function for the threshold of tasks in queue to trigger a new thread. 
+ * Access function for the threshold of tasks in queue to trigger a new thread.
  * @param me The thread pool
  * @param cnt The new threshold
  * @return The original threshold
  */
-APR_DECLARE(apr_size_t) apr_thread_pool_threshold_set(apr_thread_pool_t * me,
+APU_DECLARE(apr_size_t) apr_thread_pool_threshold_set(apr_thread_pool_t *me,
                                                       apr_size_t val);
 
 /**
- * Access function for the threshold of tasks in queue to trigger a new thread. 
+ * Access function for the threshold of tasks in queue to trigger a new thread.
  * @param me The thread pool
  * @return The current threshold
  */
-APR_DECLARE(apr_size_t) apr_thread_pool_threshold_get(apr_thread_pool_t * me);
+APU_DECLARE(apr_size_t) apr_thread_pool_threshold_get(apr_thread_pool_t * me);
 
 /**
- * Get owner of the task currently been executed by the thread. 
- * @param thd The thread is executing a task 
+ * Get owner of the task currently been executed by the thread.
+ * @param thd The thread is executing a task
  * @param owner Pointer to receive owner of the task.
  * @return APR_SUCCESS if the owner is retrieved successfully
  */
-APR_DECLARE(apr_status_t) apr_thread_pool_task_owner_get(apr_thread_t * thd,
+APU_DECLARE(apr_status_t) apr_thread_pool_task_owner_get(apr_thread_t *thd,
                                                          void **owner);
 
 /** @} */
 
 #ifdef __cplusplus
-#if 0
-{
-#endif
 }
 #endif
 
 #endif /* APR_HAS_THREADS */
-
-#endif /* APR_THREAD_POOL_H */
-
-/* vim: set ts=4 sw=4 et cin tw=80: */
+#endif /* !APR_THREAD_POOL_H */

Modified: apr/apr-util/trunk/misc/apr_thread_pool.c
URL: http://svn.apache.org/viewvc/apr/apr-util/trunk/misc/apr_thread_pool.c?view=diff&rev=558527&r1=558526&r2=558527
==============================================================================
--- apr/apr-util/trunk/misc/apr_thread_pool.c (original)
+++ apr/apr-util/trunk/misc/apr_thread_pool.c Sun Jul 22 11:55:37 2007
@@ -295,7 +295,7 @@
     return APR_SUCCESS;
 }
 
-APR_DECLARE(apr_status_t) apr_thread_pool_create(apr_thread_pool_t ** me,
+APU_DECLARE(apr_status_t) apr_thread_pool_create(apr_thread_pool_t ** me,
                                                  apr_size_t init_threads,
                                                  apr_size_t max_threads,
                                                  apr_pool_t * pool)
@@ -330,7 +330,7 @@
     return rv;
 }
 
-APR_DECLARE(apr_status_t) apr_thread_pool_destroy(apr_thread_pool_t * me)
+APU_DECLARE(apr_status_t) apr_thread_pool_destroy(apr_thread_pool_t * me)
 {
     return apr_pool_cleanup_run(me->pool, me, thread_pool_cleanup);
 }
@@ -415,7 +415,7 @@
 *   schedule a task to run in "time" milliseconds. Find the spot in the ring where
 *   the time fits. Adjust the short_time so the thread wakes up when the time is reached.
 */
-static apr_status_t schedule_task(apr_thread_pool_t * me,
+static apr_status_t schedule_task(apr_thread_pool_t *me,
                                   apr_thread_start_t func, void *param,
                                   void *owner, apr_interval_time_t time)
 {
@@ -464,7 +464,7 @@
     return rv;
 }
 
-static apr_status_t add_task(apr_thread_pool_t * me, apr_thread_start_t func,
+static apr_status_t add_task(apr_thread_pool_t *me, apr_thread_start_t func,
                              void *param, apr_byte_t priority, int push,
                              void *owner)
 {
@@ -517,7 +517,7 @@
     return rv;
 }
 
-APR_DECLARE(apr_status_t) apr_thread_pool_push(apr_thread_pool_t * me,
+APU_DECLARE(apr_status_t) apr_thread_pool_push(apr_thread_pool_t *me,
                                                apr_thread_start_t func,
                                                void *param,
                                                apr_byte_t priority,
@@ -526,7 +526,7 @@
     return add_task(me, func, param, priority, 1, owner);
 }
 
-APR_DECLARE(apr_status_t) apr_thread_pool_schedule(apr_thread_pool_t * me,
+APU_DECLARE(apr_status_t) apr_thread_pool_schedule(apr_thread_pool_t *me,
                                                    apr_thread_start_t func,
                                                    void *param,
                                                    apr_interval_time_t time,
@@ -535,7 +535,7 @@
     return schedule_task(me, func, param, owner, time);
 }
 
-APR_DECLARE(apr_status_t) apr_thread_pool_top(apr_thread_pool_t * me,
+APU_DECLARE(apr_status_t) apr_thread_pool_top(apr_thread_pool_t *me,
                                               apr_thread_start_t func,
                                               void *param,
                                               apr_byte_t priority,
@@ -544,7 +544,7 @@
     return add_task(me, func, param, priority, 0, owner);
 }
 
-static apr_status_t remove_scheduled_tasks(apr_thread_pool_t * me,
+static apr_status_t remove_scheduled_tasks(apr_thread_pool_t *me,
                                            void *owner)
 {
     apr_thread_pool_task_t *t_loc;
@@ -565,7 +565,7 @@
     return APR_SUCCESS;
 }
 
-static apr_status_t remove_tasks(apr_thread_pool_t * me, void *owner)
+static apr_status_t remove_tasks(apr_thread_pool_t *me, void *owner)
 {
     apr_thread_pool_task_t *t_loc;
     apr_thread_pool_task_t *next;
@@ -593,7 +593,7 @@
     return APR_SUCCESS;
 }
 
-static void wait_on_busy_threads(apr_thread_pool_t * me, void *owner)
+static void wait_on_busy_threads(apr_thread_pool_t *me, void *owner)
 {
 #ifndef NDEBUG
     apr_os_thread_t *os_thread;
@@ -627,7 +627,7 @@
     return;
 }
 
-APR_DECLARE(apr_status_t) apr_thread_pool_tasks_cancel(apr_thread_pool_t * me,
+APU_DECLARE(apr_status_t) apr_thread_pool_tasks_cancel(apr_thread_pool_t *me,
                                                        void *owner)
 {
     apr_status_t rv = APR_SUCCESS;
@@ -645,33 +645,33 @@
     return rv;
 }
 
-APR_DECLARE(apr_size_t) apr_thread_pool_tasks_count(apr_thread_pool_t * me)
+APU_DECLARE(apr_size_t) apr_thread_pool_tasks_count(apr_thread_pool_t *me)
 {
     return me->task_cnt;
 }
 
-APR_DECLARE(apr_size_t)
-    apr_thread_pool_scheduled_tasks_count(apr_thread_pool_t * me)
+APU_DECLARE(apr_size_t)
+    apr_thread_pool_scheduled_tasks_count(apr_thread_pool_t *me)
 {
     return me->scheduled_task_cnt;
 }
 
-APR_DECLARE(apr_size_t) apr_thread_pool_threads_count(apr_thread_pool_t * me)
+APU_DECLARE(apr_size_t) apr_thread_pool_threads_count(apr_thread_pool_t *me)
 {
     return me->thd_cnt;
 }
 
-APR_DECLARE(apr_size_t) apr_thread_pool_busy_count(apr_thread_pool_t * me)
+APU_DECLARE(apr_size_t) apr_thread_pool_busy_count(apr_thread_pool_t *me)
 {
     return me->thd_cnt - me->idle_cnt;
 }
 
-APR_DECLARE(apr_size_t) apr_thread_pool_idle_count(apr_thread_pool_t * me)
+APU_DECLARE(apr_size_t) apr_thread_pool_idle_count(apr_thread_pool_t *me)
 {
     return me->idle_cnt;
 }
 
-APR_DECLARE(apr_size_t) apr_thread_pool_idle_max_get(apr_thread_pool_t * me)
+APU_DECLARE(apr_size_t) apr_thread_pool_idle_max_get(apr_thread_pool_t *me)
 {
     return me->idle_max;
 }
@@ -681,8 +681,8 @@
  * @return the number of threads stopped
  * NOTE: There could be busy threads become idle during this function
  */
-static struct apr_thread_list_elt *trim_threads(apr_thread_pool_t * me,
-                                                apr_size_t * cnt, int idle)
+static struct apr_thread_list_elt *trim_threads(apr_thread_pool_t *me,
+                                                apr_size_t *cnt, int idle)
 {
     struct apr_thread_list *thds;
     apr_size_t n, n_dbg, i;
@@ -730,7 +730,7 @@
     return head;
 }
 
-static apr_size_t trim_idle_threads(apr_thread_pool_t * me, apr_size_t cnt)
+static apr_size_t trim_idle_threads(apr_thread_pool_t *me, apr_size_t cnt)
 {
     apr_size_t n_dbg;
     struct apr_thread_list_elt *elt;
@@ -756,13 +756,13 @@
 /* don't join on busy threads for performance reasons, who knows how long will
  * the task takes to perform
  */
-static apr_size_t trim_busy_threads(apr_thread_pool_t * me, apr_size_t cnt)
+static apr_size_t trim_busy_threads(apr_thread_pool_t *me, apr_size_t cnt)
 {
     trim_threads(me, &cnt, 0);
     return cnt;
 }
 
-APR_DECLARE(apr_size_t) apr_thread_pool_idle_max_set(apr_thread_pool_t * me,
+APU_DECLARE(apr_size_t) apr_thread_pool_idle_max_set(apr_thread_pool_t *me,
                                                      apr_size_t cnt)
 {
     me->idle_max = cnt;
@@ -770,7 +770,7 @@
     return cnt;
 }
 
-APR_DECLARE(apr_size_t) apr_thread_pool_thread_max_get(apr_thread_pool_t * me)
+APU_DECLARE(apr_size_t) apr_thread_pool_thread_max_get(apr_thread_pool_t *me)
 {
     return me->thd_max;
 }
@@ -779,7 +779,7 @@
  * This function stop extra working threads to the new limit.
  * NOTE: There could be busy threads become idle during this function
  */
-APR_DECLARE(apr_size_t) apr_thread_pool_thread_max_set(apr_thread_pool_t * me,
+APU_DECLARE(apr_size_t) apr_thread_pool_thread_max_set(apr_thread_pool_t *me,
                                                        apr_size_t cnt)
 {
     unsigned int n;
@@ -800,12 +800,12 @@
     return n;
 }
 
-APR_DECLARE(apr_size_t) apr_thread_pool_threshold_get(apr_thread_pool_t * me)
+APU_DECLARE(apr_size_t) apr_thread_pool_threshold_get(apr_thread_pool_t *me)
 {
     return me->threshold;
 }
 
-APR_DECLARE(apr_size_t) apr_thread_pool_threshold_set(apr_thread_pool_t * me,
+APU_DECLARE(apr_size_t) apr_thread_pool_threshold_set(apr_thread_pool_t *me,
                                                       apr_size_t val)
 {
     apr_size_t ov;
@@ -815,13 +815,13 @@
     return ov;
 }
 
-APR_DECLARE(apr_status_t) apr_thread_pool_task_owner_get(apr_thread_t * thd,
+APU_DECLARE(apr_status_t) apr_thread_pool_task_owner_get(apr_thread_t *thd,
                                                          void **owner)
 {
     apr_status_t rv;
     apr_thread_pool_task_t *task;
     void *data;
-    
+
     rv = apr_thread_data_get(&data, "apr_thread_pool_task", thd);
     if (rv != APR_SUCCESS) {
         return rv;
@@ -832,7 +832,7 @@
         *owner = NULL;
         return APR_BADARG;
     }
-    
+
     *owner = task->owner;
     return APR_SUCCESS;
 }