summaryrefslogtreecommitdiff
path: root/include/asterisk
diff options
context:
space:
mode:
authorLuigi Rizzo <rizzo@icir.org>2006-03-30 16:09:23 +0000
committerLuigi Rizzo <rizzo@icir.org>2006-03-30 16:09:23 +0000
commit6d2fbc0b909d9802f67345630cb967311d72eb1c (patch)
tree9e145b6bf6d89bf4b27bffc549c732dead7d0a65 /include/asterisk
parent4ee62f1bcd04a3d7bfb92268cf8444c06d01a758 (diff)
document why there are so many versions of the mutex functions,
with their pros and cons, and that we should converge to a single method. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@16528 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'include/asterisk')
-rw-r--r--include/asterisk/lock.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/include/asterisk/lock.h b/include/asterisk/lock.h
index 53c56a544..2253a455b 100644
--- a/include/asterisk/lock.h
+++ b/include/asterisk/lock.h
@@ -18,6 +18,33 @@
/*! \file
* \brief General Asterisk channel locking definitions.
+ *
+ * This file provides several different implementation of the functions,
+ * depending on the platform, the use of DEBUG_THREADS, and the way
+ * global mutexes are initialized.
+ * At the moment, we have 3 ways to initialize global mutexes, depending on
+ *
+ * + static: the mutex is assigned the value AST_MUTEX_INIT_VALUE
+ * this is done at compile time, and is the way used on Linux.
+ * This method is not applicable to all platforms e.g. when the
+ * initialization needs that some code is run.
+ *
+ * + on first use: the mutex is assigned a magic value at compile time,
+ * and ast_mutex_init() is called when this magic value is detected.
+ * This technique is generally applicable, though it has a bit of
+ * overhead on each access to check whether initialization is needed.
+ * On the other hand, the overall cost of a mutex_lock operation
+ * is such that this overhead is often negligible.
+
+ * + through constructors: for each mutex, a constructor function is
+ * defined, which then runs when the program (or the module)
+ * starts. The problem with this approach is that there is a
+ * lot of code duplication (a new block of code is created for
+ * each mutex). Also, it does not prevent a user from declaring
+ * a global mutex without going through the wrapper macros,
+ * so sane programming practices are still required.
+ *
+ * Eventually we should converge on a single method for all platforms.
*/
#ifndef _ASTERISK_LOCK_H