[asterisk-commits] kmoore: branch kmoore/scheduler r430276 - in /team/kmoore/scheduler: include/...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jan 6 21:02:37 CST 2015


Author: kmoore
Date: Tue Jan  6 21:02:34 2015
New Revision: 430276

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=430276
Log:
Do some renaming

Modified:
    team/kmoore/scheduler/include/asterisk/sched2.h
    team/kmoore/scheduler/main/sched2.c

Modified: team/kmoore/scheduler/include/asterisk/sched2.h
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/scheduler/include/asterisk/sched2.h?view=diff&rev=430276&r1=430275&r2=430276
==============================================================================
--- team/kmoore/scheduler/include/asterisk/sched2.h (original)
+++ team/kmoore/scheduler/include/asterisk/sched2.h Tue Jan  6 21:02:34 2015
@@ -29,18 +29,23 @@
 #endif
 
 /*!
+ * \brief A structure that represents a scheduler context
+ */
+struct as2_context;
+
+/*!
  * \brief Create a scheduler context
  *
- * \return Returns a malloc'd sched_context structure, NULL on failure
- */
-struct ast_sched_context *ast_sched_context_create(void);
+ * \return Returns a malloc'd as2_context structure, NULL on failure
+ */
+struct as2_context *as2_context_create(void);
 
 /*!
  * \brief destroys a schedule context
  *
  * \param c Context to free
  */
-void ast_sched_context_destroy(struct ast_sched_context *c);
+void as2_context_destroy(struct as2_context *c);
 
 /*!
  * \brief scheduler callback
@@ -52,13 +57,13 @@
  * \retval 0 if the callback should not be rescheduled
  * \retval non-zero if the callback should be scheduled again
  */
-typedef int (*ast_sched_cb)(void *obj);
-#define AST_SCHED_CB(a) ((ast_sched_cb)(a))
+typedef int (*as2_cb)(void *obj);
+#define AST_SCHED_CB(a) ((as2_cb)(a))
 
 struct ast_cb_names {
 	int numassocs;
 	char *list[10];
-	ast_sched_cb cblist[10];
+	as2_cb cblist[10];
 };
 
 /*!
@@ -69,7 +74,7 @@
  * \param cbnames to check against
  * \since 1.6.1
  */
-void ast_sched_report(struct ast_sched_context *con, struct ast_str **buf, struct ast_cb_names *cbnames);
+void as2_report(struct as2_context *con, struct ast_str **buf, struct ast_cb_names *cbnames);
 
 /*!
  * \brief Adds a scheduled event
@@ -87,7 +92,7 @@
  *
  * \return Returns a schedule item ID on success, -1 on failure
  */
-#define ast_sched_add(con, when, callback, obj) ast_sched_add_variable(con, when, callback, obj, 0)
+#define as2_add(con, when, callback, obj) as2_add_variable(con, when, callback, obj, 0)
 
 /*!
  * \brief Adds a scheduled event with rescheduling support
@@ -107,7 +112,7 @@
  *
  * \return Returns a schedule item ID on success, -1 on failure
  */
-int ast_sched_add_variable(struct ast_sched_context *con, int when, ast_sched_cb callback, void *obj, int variable) attribute_warn_unused_result;
+int as2_add_variable(struct as2_context *con, int when, as2_cb callback, void *obj, int variable) attribute_warn_unused_result;
 
 /*! 
  * \brief Find a sched structure and return the data field associated with it. 
@@ -119,7 +124,7 @@
  * \return the AO2 object from the matching scheduled event (must be ao2_cleanup()d)
  * \return NULL if not found or object not provided
  */
-void *ast_sched_find_data(struct ast_sched_context *con, int id);
+void *as2_find_data(struct as2_context *con, int id);
 
 /*!
  * \brief Deletes a scheduled event
@@ -135,10 +140,10 @@
  * \return Returns 0 on success, -1 on failure
  */
 #ifndef AST_DEVMODE
-int ast_sched_del(struct ast_sched_context *con, int id) attribute_warn_unused_result;
+int as2_del(struct as2_context *con, int id) attribute_warn_unused_result;
 #else
-int _ast_sched_del(struct ast_sched_context *con, int id, const char *file, int line, const char *function) attribute_warn_unused_result;
-#define	ast_sched_del(a, b)	_ast_sched_del(a, b, __FILE__, __LINE__, __PRETTY_FUNCTION__)
+int _as2_del(struct as2_context *con, int id, const char *file, int line, const char *function) attribute_warn_unused_result;
+#define	as2_del(a, b)	_as2_del(a, b, __FILE__, __LINE__, __PRETTY_FUNCTION__)
 #endif
 
 /*!
@@ -154,7 +159,7 @@
  * \return Returns "-1" if there is nothing there are no scheduled events
  * (and thus the poll should not timeout)
  */
-int ast_sched_wait(struct ast_sched_context *con) attribute_warn_unused_result;
+int as2_wait(struct as2_context *con) attribute_warn_unused_result;
 
 /*!
  * \brief Runs the queue
@@ -167,7 +172,7 @@
  *
  * \return Returns the number of events processed.
  */
-int ast_sched_runq(struct ast_sched_context *con);
+int as2_runq(struct as2_context *con);
 
 /*!
  * \brief Dumps the scheduler contents
@@ -176,7 +181,7 @@
  *
  * \param con Context to dump
  */
-void ast_sched_dump(struct ast_sched_context *con);
+void as2_dump(struct as2_context *con);
 
 /*!
  * \brief Returns the number of seconds before an event takes place
@@ -184,7 +189,7 @@
  * \param con Context to use
  * \param id Id to dump
  */
-long ast_sched_when(struct ast_sched_context *con,int id);
+long as2_when(struct as2_context *con,int id);
 
 /*!
  * \brief Start a thread for processing scheduler entries
@@ -194,7 +199,7 @@
  * \retval 0 success
  * \retval non-zero failure
  */
-int ast_sched_start_thread(struct ast_sched_context *con);
+int as2_start_thread(struct as2_context *con);
 
 #if defined(__cplusplus) || defined(c_plusplus)
 }

Modified: team/kmoore/scheduler/main/sched2.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/scheduler/main/sched2.c?view=diff&rev=430276&r1=430275&r2=430276
==============================================================================
--- team/kmoore/scheduler/main/sched2.c (original)
+++ team/kmoore/scheduler/main/sched2.c Tue Jan  6 21:02:34 2015
@@ -43,7 +43,7 @@
 
 #include <sys/time.h>
 
-#include "asterisk/sched.h"
+#include "asterisk/sched2.h"
 #include "asterisk/channel.h"
 #include "asterisk/lock.h"
 #include "asterisk/utils.h"
@@ -68,7 +68,7 @@
 	struct timeval when;          /*!< Absolute time event should take place */
 	int resched;                  /*!< When to reschedule */
 	void *object;                 /*!< AO2 object for callback */
-	ast_sched_cb callback;        /*!< Callback */
+	as2_cb callback;        /*!< Callback */
 	unsigned int variable:1;      /*!< Use return value from callback to reschedule */
 	unsigned int deleted:1;       /*!< Flagged for deletion during execution */
 	ssize_t __heap_index;
@@ -87,7 +87,7 @@
 	unsigned int stop:1;
 };
 
-struct ast_sched_context {
+struct as2_context {
 	ast_mutex_t lock;
 	unsigned int eventcnt;                  /*!< Number of events processed */
 	unsigned int highwater;			/*!< highest count so far */
@@ -104,7 +104,7 @@
 
 static void *sched_run(void *data)
 {
-	struct ast_sched_context *con = data;
+	struct as2_context *con = data;
 
 	while (!con->sched_thread->stop) {
 		int ms;
@@ -119,7 +119,7 @@
 			return NULL;
 		}
 
-		ms = ast_sched_wait(con);
+		ms = as2_wait(con);
 
 		if (ms == -1) {
 			ast_cond_wait(&con->sched_thread->cond, &con->lock);
@@ -137,13 +137,13 @@
 			return NULL;
 		}
 
-		ast_sched_runq(con);
+		as2_runq(con);
 	}
 
 	return NULL;
 }
 
-static void sched_thread_destroy(struct ast_sched_context *con)
+static void sched_thread_destroy(struct as2_context *con)
 {
 	if (!con->sched_thread) {
 		return;
@@ -165,7 +165,7 @@
 	con->sched_thread = NULL;
 }
 
-int ast_sched_start_thread(struct ast_sched_context *con)
+int as2_start_thread(struct as2_context *con)
 {
 	struct sched_thread *st;
 
@@ -198,9 +198,9 @@
 	return ast_tvcmp(((struct sched *) b)->when, ((struct sched *) a)->when);
 }
 
-struct ast_sched_context *ast_sched_context_create(void)
-{
-	struct ast_sched_context *tmp;
+struct as2_context *as2_context_create(void)
+{
+	struct as2_context *tmp;
 
 	if (!(tmp = ast_calloc(1, sizeof(*tmp)))) {
 		return NULL;
@@ -211,7 +211,7 @@
 
 	if (!(tmp->sched_heap = ast_heap_create(8, sched_time_cmp,
 			offsetof(struct sched, __heap_index)))) {
-		ast_sched_context_destroy(tmp);
+		as2_context_destroy(tmp);
 		return NULL;
 	}
 
@@ -224,7 +224,7 @@
 	ast_free(task);
 }
 
-void ast_sched_context_destroy(struct ast_sched_context *con)
+void as2_context_destroy(struct as2_context *con)
 {
 	struct sched *s;
 
@@ -253,7 +253,7 @@
 	ast_free(con);
 }
 
-static struct sched *sched_alloc(struct ast_sched_context *con)
+static struct sched *sched_alloc(struct as2_context *con)
 {
 	struct sched *tmp;
 
@@ -274,7 +274,7 @@
 	return tmp;
 }
 
-static void sched_release(struct ast_sched_context *con, struct sched *tmp)
+static void sched_release(struct as2_context *con, struct sched *tmp)
 {
 	/*
 	 * Add to the cache, or just free() if we
@@ -296,12 +296,12 @@
  * Return the number of milliseconds
  * until the next scheduled event
  */
-int ast_sched_wait(struct ast_sched_context *con)
+int as2_wait(struct as2_context *con)
 {
 	int ms;
 	struct sched *s;
 
-	DEBUG(ast_debug(1, "ast_sched_wait()\n"));
+	DEBUG(ast_debug(1, "as2_wait()\n"));
 
 	ast_mutex_lock(&con->lock);
 	if ((s = ast_heap_peek(con->sched_heap, 1))) {
@@ -323,7 +323,7 @@
  * queue, such that the soonest event is
  * first in the list.
  */
-static void schedule(struct ast_sched_context *con, struct sched *s)
+static void schedule(struct as2_context *con, struct sched *s)
 {
 	ast_heap_push(con->sched_heap, s);
 
@@ -350,24 +350,24 @@
 	return 0;
 }
 
-int ast_sched_replace_variable(int old_id, struct ast_sched_context *con, int when, ast_sched_cb callback, const void *data, int variable)
+int as2_replace_variable(int old_id, struct as2_context *con, int when, as2_cb callback, const void *data, int variable)
 {
 	/* 0 means the schedule item is new; do not delete */
 	if (old_id > 0) {
 		AST_SCHED_DEL(con, old_id);
 	}
-	return ast_sched_add_variable(con, when, callback, data, variable);
+	return as2_add_variable(con, when, callback, data, variable);
 }
 
 /*! \brief
  * Schedule callback(data) to happen when ms into the future
  */
-int ast_sched_add_variable(struct ast_sched_context *con, int when, ast_sched_cb callback, void *obj, int variable)
+int as2_add_variable(struct as2_context *con, int when, as2_cb callback, void *obj, int variable)
 {
 	struct sched *tmp;
 	int res = -1;
 
-	DEBUG(ast_debug(1, "ast_sched_add()\n"));
+	DEBUG(ast_debug(1, "as2_add()\n"));
 
 	ast_mutex_lock(&con->lock);
 	if ((tmp = sched_alloc(con))) {
@@ -388,7 +388,7 @@
 #ifdef DUMP_SCHEDULER
 	/* Dump contents of the context while we have the lock so nothing gets screwed up by accident. */
 	if (option_debug)
-		ast_sched_dump(con);
+		as2_dump(con);
 #endif
 	if (con->sched_thread) {
 		ast_cond_signal(&con->sched_thread->cond);
@@ -398,20 +398,20 @@
 	return res;
 }
 
-int ast_sched_replace(int old_id, struct ast_sched_context *con, int when, ast_sched_cb callback, const void *data)
+int as2_replace(int old_id, struct as2_context *con, int when, as2_cb callback, const void *data)
 {
 	if (old_id > -1) {
 		AST_SCHED_DEL(con, old_id);
 	}
-	return ast_sched_add(con, when, callback, data);
-}
-
-int ast_sched_add(struct ast_sched_context *con, int when, ast_sched_cb callback, const void *data)
-{
-	return ast_sched_add_variable(con, when, callback, data, 0);
-}
-
-static struct sched *sched_find(struct ast_sched_context *con, int id)
+	return as2_add(con, when, callback, data);
+}
+
+int as2_add(struct as2_context *con, int when, as2_cb callback, const void *data)
+{
+	return as2_add_variable(con, when, callback, data, 0);
+}
+
+static struct sched *sched_find(struct as2_context *con, int id)
 {
 	int x;
 	size_t heap_size;
@@ -428,7 +428,7 @@
 	return NULL;
 }
 
-const void *ast_sched_find_data(struct ast_sched_context *con, int id)
+const void *as2_find_data(struct as2_context *con, int id)
 {
 	struct sched *s;
 	const void *data = NULL;
@@ -452,15 +452,15 @@
  * id.
  */
 #ifndef AST_DEVMODE
-int ast_sched_del(struct ast_sched_context *con, int id)
+int as2_del(struct as2_context *con, int id)
 #else
-int _ast_sched_del(struct ast_sched_context *con, int id, const char *file, int line, const char *function)
+int _as2_del(struct as2_context *con, int id, const char *file, int line, const char *function)
 #endif
 {
 	struct sched *s = NULL;
 	int *last_id = ast_threadstorage_get(&last_del_id, sizeof(int));
 
-	DEBUG(ast_debug(1, "ast_sched_del(%d)\n", id));
+	DEBUG(ast_debug(1, "as2_del(%d)\n", id));
 
 	if (id < 0) {
 		return 0;
@@ -477,17 +477,17 @@
 	} else if (con->currently_executing && (id == con->currently_executing->id) && !con->currently_executing->deleted) {
 		s = con->currently_executing;
 		s->deleted = 1;
-		/* Wait for executing task to complete so that caller of ast_sched_del() does not
+		/* Wait for executing task to complete so that caller of as2_del() does not
 		 * free memory out from under the task.
 		 */
 		ast_cond_wait(&s->cond, &con->lock);
-		/* Do not sched_release() here because ast_sched_runq() will do it */
+		/* Do not sched_release() here because as2_runq() will do it */
 	}
 
 #ifdef DUMP_SCHEDULER
 	/* Dump contents of the context while we have the lock so nothing gets screwed up by accident. */
 	if (option_debug)
-		ast_sched_dump(con);
+		as2_dump(con);
 #endif
 	if (con->sched_thread) {
 		ast_cond_signal(&con->sched_thread->cond);
@@ -515,7 +515,7 @@
 	return 0;
 }
 
-void ast_sched_report(struct ast_sched_context *con, struct ast_str **buf, struct ast_cb_names *cbnames)
+void as2_report(struct as2_context *con, struct ast_str **buf, struct ast_cb_names *cbnames)
 {
 	int i, x;
 	struct sched *cur;
@@ -553,7 +553,7 @@
 }
 
 /*! \brief Dump the contents of the scheduler to LOG_DEBUG */
-void ast_sched_dump(struct ast_sched_context *con)
+void as2_dump(struct as2_context *con)
 {
 	struct sched *q;
 	struct timeval when = ast_tvnow();
@@ -588,13 +588,13 @@
 /*! \brief
  * Launch all events which need to be run at this time.
  */
-int ast_sched_runq(struct ast_sched_context *con)
+int as2_runq(struct as2_context *con)
 {
 	struct timeval when;
 	int numevents;
 	int res;
 
-	DEBUG(ast_debug(1, "ast_sched_runq()\n"));
+	DEBUG(ast_debug(1, "as2_runq()\n"));
 
 	ast_mutex_lock(&con->lock);
 
@@ -649,11 +649,11 @@
 	return numevents;
 }
 
-long ast_sched_when(struct ast_sched_context *con,int id)
+long as2_when(struct as2_context *con,int id)
 {
 	struct sched *s;
 	long secs = -1;
-	DEBUG(ast_debug(1, "ast_sched_when()\n"));
+	DEBUG(ast_debug(1, "as2_when()\n"));
 
 	ast_mutex_lock(&con->lock);
 




More information about the asterisk-commits mailing list