[asterisk-commits] dhubbard: branch dhubbard/named_processors r108674 - in /team/dhubbard/named_...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Mar 13 22:27:49 CDT 2008


Author: dhubbard
Date: Thu Mar 13 22:27:49 2008
New Revision: 108674

URL: http://svn.digium.com/view/asterisk?view=rev&rev=108674
Log:
move the taskproducer stuff into taskprocessor.c; delete taskproducer.h

Removed:
    team/dhubbard/named_processors/include/asterisk/taskproducer.h
    team/dhubbard/named_processors/main/taskproducer.c
Modified:
    team/dhubbard/named_processors/apps/app_queue.c
    team/dhubbard/named_processors/include/asterisk/taskprocessor.h
    team/dhubbard/named_processors/main/Makefile
    team/dhubbard/named_processors/main/taskprocessor.c
    team/dhubbard/named_processors/res/sandbox/simobject.c

Modified: team/dhubbard/named_processors/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/team/dhubbard/named_processors/apps/app_queue.c?view=diff&rev=108674&r1=108673&r2=108674
==============================================================================
--- team/dhubbard/named_processors/apps/app_queue.c (original)
+++ team/dhubbard/named_processors/apps/app_queue.c Thu Mar 13 22:27:49 2008
@@ -94,7 +94,6 @@
 #include "asterisk/global_datastores.h"
 #include "asterisk/taskprocessor.h"
 #include "asterisk/task.h"
-#include "asterisk/taskproducer.h"
 
 /*!
  * \par Please read before modifying this file.

Modified: team/dhubbard/named_processors/include/asterisk/taskprocessor.h
URL: http://svn.digium.com/view/asterisk/team/dhubbard/named_processors/include/asterisk/taskprocessor.h?view=diff&rev=108674&r1=108673&r2=108674
==============================================================================
--- team/dhubbard/named_processors/include/asterisk/taskprocessor.h (original)
+++ team/dhubbard/named_processors/include/asterisk/taskprocessor.h Thu Mar 13 22:27:49 2008
@@ -47,6 +47,13 @@
 	AST_LIST_ENTRY(taskprocessor_singleton_info) list;
 };
 
+struct taskproducer {
+	struct taskprocessor_singleton_info* _taskprocessor;
+	unsigned long _tasks_produced;
+
+	int (* queue_task)(struct taskproducer* producer, struct a_task* task);
+}; 
+
 unsigned char _evtq_poll_thread_run;
 
 int create_taskprocessor_singleton(const char* name, void* (*func)(void*));
@@ -63,5 +70,7 @@
 
 int register_taskprocessor_clis(void);
 int unregister_taskprocessor_clis(void);
+
+struct taskproducer* construct_taskproducer(struct taskprocessor_singleton_info* processor);
 #endif
 

Modified: team/dhubbard/named_processors/main/Makefile
URL: http://svn.digium.com/view/asterisk/team/dhubbard/named_processors/main/Makefile?view=diff&rev=108674&r1=108673&r2=108674
==============================================================================
--- team/dhubbard/named_processors/main/Makefile (original)
+++ team/dhubbard/named_processors/main/Makefile Thu Mar 13 22:27:49 2008
@@ -30,7 +30,7 @@
 	cryptostub.o sha1.o http.o fixedjitterbuf.o abstract_jb.o \
 	strcompat.o threadstorage.o dial.o event.o adsistub.o audiohook.o \
 	astobj2.o hashtab.o global_datastores.o $(RESAMPLE_OBJS) version.o \
-	features.o task.o taskprocessor.o taskproducer.o
+	features.o task.o taskprocessor.o
 
 # we need to link in the objects statically, not as a library, because
 # otherwise modules will not have them available if none of the static

Modified: team/dhubbard/named_processors/main/taskprocessor.c
URL: http://svn.digium.com/view/asterisk/team/dhubbard/named_processors/main/taskprocessor.c?view=diff&rev=108674&r1=108673&r2=108674
==============================================================================
--- team/dhubbard/named_processors/main/taskprocessor.c (original)
+++ team/dhubbard/named_processors/main/taskprocessor.c Thu Mar 13 22:27:49 2008
@@ -521,3 +521,34 @@
 	return size;
 }
 
+/* provide a default implementation of a queue() command */
+static int default_queue_task(struct taskproducer* producer, struct a_task* task)
+{
+	if ((!producer) || (!task)) {
+		ast_log(LOG_ERROR, "a taskproducer: 0x%ld and a task: 0x%ld are required for this operation.\n", (unsigned long)producer, (unsigned long)task);
+		return -1;
+	}
+	if (push_task_to_taskprocessor_singleton(producer->_taskprocessor, task) < 0) {
+		ast_log(LOG_ERROR, "we failed to push task to taskprocessor \'%s\'.\n", (producer->_taskprocessor)?producer->_taskprocessor->_name:"<null>");
+		return -1;
+	}
+	producer->_tasks_produced++;
+	ast_mutex_lock(&producer->_taskprocessor->_taskprocessor_lock);
+	ast_cond_signal(&producer->_taskprocessor->_poll_cond);
+	ast_mutex_unlock(&producer->_taskprocessor->_taskprocessor_lock);
+	return 0;
+}
+
+/* create and initialize a task producer */
+struct taskproducer* construct_taskproducer(struct taskprocessor_singleton_info* processor)
+{
+	struct taskproducer* p;
+	p = ast_calloc(1, sizeof(*p));
+	if (!p) {
+		ast_log(LOG_ERROR, "cannot allocate memory for a taskproducer structure.\n");
+		return NULL;
+	}
+	p->_taskprocessor = processor;
+	p->queue_task = default_queue_task;
+	return p;
+}

Modified: team/dhubbard/named_processors/res/sandbox/simobject.c
URL: http://svn.digium.com/view/asterisk/team/dhubbard/named_processors/res/sandbox/simobject.c?view=diff&rev=108674&r1=108673&r2=108674
==============================================================================
--- team/dhubbard/named_processors/res/sandbox/simobject.c (original)
+++ team/dhubbard/named_processors/res/sandbox/simobject.c Thu Mar 13 22:27:49 2008
@@ -16,7 +16,8 @@
  * at the top of the source tree.
  */
 #include <asterisk.h>
-#include <asterisk/taskproducer.h>
+#include <asterisk/task.h>
+#include <asterisk/taskprocessor.h>
 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 
 #include "include/simobject.h"




More information about the asterisk-commits mailing list