[Asterisk-code-review] taskprocessor.c: New API for human friendly taskprocessor na... (asterisk[master])

Richard Mudgett asteriskteam at digium.com
Fri Jan 8 14:08:22 CST 2016


Richard Mudgett has uploaded a new change for review.

  https://gerrit.asterisk.org/1955

Change subject: taskprocessor.c: New API for human friendly taskprocessor names.
......................................................................

taskprocessor.c: New API for human friendly taskprocessor names.

Add new API call to get a sequence number for use in human friendly
taskprocessor names.

Change-Id: Iac458f05b45232315ed64aa31b1df05b875537a9
---
M include/asterisk/taskprocessor.h
M main/taskprocessor.c
2 files changed, 18 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/55/1955/1

diff --git a/include/asterisk/taskprocessor.h b/include/asterisk/taskprocessor.h
index 6ebf072..6ae56f6 100644
--- a/include/asterisk/taskprocessor.h
+++ b/include/asterisk/taskprocessor.h
@@ -56,6 +56,9 @@
 
 struct ast_taskprocessor;
 
+/*! \brief Suggested maximum taskprocessor name length (less null terminator). */
+#define AST_TASKPROCESSOR_MAX_NAME	45
+
 #define AST_TASKPROCESSOR_HIGH_WATER_LEVEL 500
 
 /*!
@@ -259,6 +262,14 @@
 int ast_taskprocessor_is_task(struct ast_taskprocessor *tps);
 
 /*!
+ * \brief Get the next sequence number to create a human friendly taskprocessor name.
+ * \since 13.8.0
+ *
+ * \return Sequence number for use in creating human friendly taskprocessor names.
+ */
+unsigned int ast_taskprocessor_seq_num(void);
+
+/*!
  * \brief Return the name of the taskprocessor singleton
  * \since 1.6.1
  */
diff --git a/main/taskprocessor.c b/main/taskprocessor.c
index 0b67c0f..d6792aa 100644
--- a/main/taskprocessor.c
+++ b/main/taskprocessor.c
@@ -879,3 +879,10 @@
 	ao2_unlock(tps);
 	return is_task;
 }
+
+unsigned int ast_taskprocessor_seq_num(void)
+{
+	static int seq_num;
+
+	return (unsigned int) ast_atomic_fetchadd_int(&seq_num, +1);
+}

-- 
To view, visit https://gerrit.asterisk.org/1955
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iac458f05b45232315ed64aa31b1df05b875537a9
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Richard Mudgett <rmudgett at digium.com>



More information about the asterisk-code-review mailing list