summaryrefslogtreecommitdiff
path: root/include/asterisk/devicestate.h
diff options
context:
space:
mode:
authorRussell Bryant <russell@russellbryant.com>2009-03-25 21:57:19 +0000
committerRussell Bryant <russell@russellbryant.com>2009-03-25 21:57:19 +0000
commitee77b475f2177c07e4208d24d9258e9ebc4008b5 (patch)
treefddbbf5a3e995692c45ca8a1952d3319299a01c6 /include/asterisk/devicestate.h
parent9ae51a21c0a247d1ebf2373660064b53fb6d387a (diff)
Improve performance of the ast_event cache functionality.
This code comes from svn/asterisk/team/russell/event_performance/. Here is a summary of the changes that have been made, in order of both invasiveness and performance impact, from smallest to largest. 1) Asterisk 1.6.1 introduces some additional logic to be able to handle distributed device state. This functionality comes at a cost. One relatively minor change in this patch is that the extra processing required for distributed device state is now completely bypassed if it's not needed. 2) One of the things that I noticed when profiling this code was that a _lot_ of time was spent doing string comparisons. I changed the way strings are represented in an event to include a hash value at the front. So, before doing a string comparison, we do an integer comparison on the hash. 3) Finally, the code that handles the event cache has been re-written. I tried to do this in a such a way that it had minimal impact on the API. I did have to change one API call, though - ast_event_queue_and_cache(). However, the way it works now is nicer, IMO. Each type of event that can be cached (MWI, device state) has its own hash table and rules for hashing and comparing objects. This by far made the biggest impact on performance. For additional details regarding this code and how it was tested, please see the review request. (closes issue #14738) Reported by: russell Review: http://reviewboard.digium.com/r/205/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@184339 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'include/asterisk/devicestate.h')
-rw-r--r--include/asterisk/devicestate.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/include/asterisk/devicestate.h b/include/asterisk/devicestate.h
index fe911bacf..e4634a797 100644
--- a/include/asterisk/devicestate.h
+++ b/include/asterisk/devicestate.h
@@ -37,6 +37,8 @@
#ifndef _ASTERISK_DEVICESTATE_H
#define _ASTERISK_DEVICESTATE_H
+#include "asterisk/channel.h"
+
#if defined(__cplusplus) || defined(c_plusplus)
extern "C" {
#endif
@@ -260,6 +262,21 @@ struct ast_devstate_aggregate {
unsigned int ring:1;
};
+/*!
+ * \brief Enable distributed device state processing.
+ *
+ * \details
+ * By default, Asterisk assumes that device state change events will only be
+ * originating from one instance. If a module gets loaded and configured such
+ * that multiple instances of Asterisk will be sharing device state, this
+ * function should be called to enable distributed device state processing.
+ * It is off by default to save on unnecessary processing.
+ *
+ * \retval 0 success
+ * \retval -1 failure
+ */
+int ast_enable_distributed_devstate(void);
+
#if defined(__cplusplus) || defined(c_plusplus)
}
#endif