mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-04 03:20:33 +00:00
Prior to this patch, all Stasis subscriptions would receive a dedicated thread for servicing published messages. In contrast, prior to r400178 (see review https://reviewboard.asterisk.org/r/2881/), the subscriptions shared a thread pool. It was discovered during some initial work on Stasis that, for a low subscription count with high message throughput, the threadpool was not as performant as simply having a dedicated thread per subscriber. For situations where a subscriber receives a substantial number of messages and is always present, the model of having a dedicated thread per subscriber makes sense. While we still have plenty of subscriptions that would follow this model, e.g., AMI, CDRs, CEL, etc., there are plenty that also fall into the following two categories: * Large number of subscriptions, specifically those tied to endpoints/peers. * Low number of messages. Some subscriptions exist specifically to coordinate a single message - the subscription is created, a message is published, the delivery is synchronized, and the subscription is destroyed. In both of the latter two cases, creating a dedicated thread is wasteful (and in the case of a large number of peers/endpoints, harmful). In those cases, having shared delivery threads is far more performant. This patch adds the ability of a subscriber to Stasis to choose whether or not their messages are dispatched on a dedicated thread or on a threadpool. The threadpool is configurable through stasis.conf. Review: https://reviewboard.asterisk.org/r/4193 ASTERISK-24533 #close Reported by: xrobau Tested by: xrobau ........ Merged revisions 428681 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/13@428687 65c4cc65-6c06-0410-ace0-fbb531ad65f3
71 lines
2.3 KiB
C
71 lines
2.3 KiB
C
/*
|
|
* Asterisk -- An open source telephony toolkit.
|
|
*
|
|
* Copyright (C) 2013, Digium, Inc.
|
|
*
|
|
* Matt Jordan <mjordan@digium.com>
|
|
*
|
|
* See http://www.asterisk.org for more information about
|
|
* the Asterisk project. Please do not directly contact
|
|
* any of the maintainers of this project for assistance;
|
|
* the project provides a web site, mailing lists and IRC
|
|
* channels for your use.
|
|
*
|
|
* This program is free software, distributed under the terms of
|
|
* the GNU General Public License Version 2. See the LICENSE file
|
|
* at the top of the source tree.
|
|
*/
|
|
|
|
/*! \file
|
|
*
|
|
* \brief Internal Stasis APIs.
|
|
*
|
|
* This header file is used to define functions that are shared between files that make
|
|
* up \ref stasis. Functions declared here should not be used by any module outside of
|
|
* Stasis.
|
|
*
|
|
* If you find yourself needing to call one of these functions directly, something has
|
|
* probably gone horribly wrong.
|
|
*
|
|
* \author Matt Jordan <mjordan@digium.com>
|
|
*/
|
|
|
|
#include "asterisk/stasis.h"
|
|
|
|
#ifndef STASIS_INTERNAL_H_
|
|
#define STASIS_INTERNAL_H_
|
|
|
|
/*!
|
|
* \brief Create a subscription.
|
|
*
|
|
* In addition to being AO2 managed memory (requiring an ao2_cleanup() to free
|
|
* up this reference), the subscription must be explicitly unsubscribed from its
|
|
* topic using stasis_unsubscribe().
|
|
*
|
|
* The invocations of the callback are serialized, but may not always occur on
|
|
* the same thread. The invocation order of different subscriptions is
|
|
* unspecified.
|
|
*
|
|
* Note: modules outside of Stasis should use \ref stasis_subscribe.
|
|
*
|
|
* \param topic Topic to subscribe to.
|
|
* \param callback Callback function for subscription messages.
|
|
* \param data Data to be passed to the callback, in addition to the message.
|
|
* \param needs_mailbox Determines whether or not the subscription requires a mailbox.
|
|
* Subscriptions with mailboxes will be delivered on some non-publisher thread;
|
|
* subscriptions without mailboxes will be delivered on the publisher thread.
|
|
* \param use_thread_pool Use the thread pool for the subscription. This is only
|
|
* relevant if \c needs_mailbox is non-zero.
|
|
* \return New \ref stasis_subscription object.
|
|
* \return \c NULL on error.
|
|
* \since 12
|
|
*/
|
|
struct stasis_subscription *internal_stasis_subscribe(
|
|
struct stasis_topic *topic,
|
|
stasis_subscription_cb callback,
|
|
void *data,
|
|
int needs_mailbox,
|
|
int use_thread_pool);
|
|
|
|
#endif /* STASIS_INTERNAL_H_ */
|