diff options
author | Mark Michelson <mmichelson@digium.com> | 2012-11-19 21:31:32 +0000 |
---|---|---|
committer | Mark Michelson <mmichelson@digium.com> | 2012-11-19 21:31:32 +0000 |
commit | f4328e109d5a5d549181c021f506477766702167 (patch) | |
tree | 26edc2d66719eb408425d3287af940ef5d16af7c /include | |
parent | ff06346ea24c8a127c19d412a48d09f092b727c3 (diff) |
Reorganize code and change behavior of ast_taskprocessor_execute() when taskprocessor is shutting down.
Moved code around to be easier to follow.
ast_taskprocessor_execute() will now return 0 if the taskprocessor is being shut down.
git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@376499 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'include')
-rw-r--r-- | include/asterisk/taskprocessor.h | 41 |
1 files changed, 23 insertions, 18 deletions
diff --git a/include/asterisk/taskprocessor.h b/include/asterisk/taskprocessor.h index f2cf4c63c..7f80e0269 100644 --- a/include/asterisk/taskprocessor.h +++ b/include/asterisk/taskprocessor.h @@ -22,28 +22,33 @@ * * \author Dwayne M. Hubbard <dhubbard@digium.com> * - * \note A taskprocessor is a named singleton containing a task queue that serializes tasks pushed - * into it by [a] module(s) that reference the taskprocessor. A taskprocessor is created the first - * time its name is requested via the ast_taskprocessor_get() function and destroyed when the - * taskprocessor reference count reaches zero. A taskprocessor also contains an accompanying - * listener that is told when changes in the task queue occur. + * \note A taskprocessor is a named singleton containing a task queue that + * serializes tasks pushed into it by [a] module(s) that reference the taskprocessor. + * A taskprocessor is created the first time its name is requested via the + * ast_taskprocessor_get() function or the ast_taskprocessor_create_with_listener() + * function and destroyed when the taskprocessor reference count reaches zero. A + * taskprocessor also contains an accompanying listener that is notified when changes + * in the task queue occur. * * A task is a wrapper around a task-handling function pointer and a data * pointer. A task is pushed into a taskprocessor queue using the * ast_taskprocessor_push(taskprocessor, taskhandler, taskdata) function and freed by the - * taskprocessor after the task handling function returns. A module releases its reference to a - * taskprocessor using the ast_taskprocessor_unreference() function which may result in the - * destruction of the taskprocessor if the taskprocessor's reference count reaches zero. Tasks waiting - * to be processed in the taskprocessor queue when the taskprocessor reference count reaches zero - * will be purged and released from the taskprocessor queue without being processed. - * - * The taskprocessor listener has the flexibility of doling out tasks to best fit the module's - * needs. For instance, a taskprocessor listener may have a single dispatch thread that handles - * all tasks, or it may dispatch tasks to a thread pool. - * - * There is a default taskprocessor listener that will be used if a taskprocessor is created without - * a listener. This default listener runs tasks sequentially in a single thread. The listener will - * execute tasks as long as there are tasks to be processed. + * taskprocessor after the task handling function returns. A module releases its + * reference to a taskprocessor using the ast_taskprocessor_unreference() function which + * may result in the destruction of the taskprocessor if the taskprocessor's reference + * count reaches zero. When the taskprocessor's reference count reaches zero, its + * listener's shutdown() callback will be called. Any further attempts to execute tasks + * will be denied. + * + * The taskprocessor listener has the flexibility of doling out tasks to best fit the + * module's needs. For instance, a taskprocessor listener may have a single dispatch + * thread that handles all tasks, or it may dispatch tasks to a thread pool. + * + * There is a default taskprocessor listener that will be used if a taskprocessor is + * created without any explicit listener. This default listener runs tasks sequentially + * in a single thread. The listener will execute tasks as long as there are tasks to be + * processed. When the taskprocessor is shut down, the default listener will stop + * processing tasks and join its execution thread. */ #ifndef __AST_TASKPROCESSOR_H__ |