66 struct timeval delta = {
67 .tv_sec = timeout_millis / 1000,
68 .tv_usec = (timeout_millis % 1000) * 1000,
70 struct timeval deadline_tv =
ast_tvadd(start, delta);
71 struct timespec deadline = {
72 .tv_sec = deadline_tv.tv_sec,
73 .tv_nsec = 1000 * deadline_tv.tv_usec,
89 sink->max_messages = 4;
91 ast_malloc(
sizeof(*sink->messages) * sink->max_messages);
92 if (!sink->messages) {
130 sizeof(*new_messages) * new_max_messages);
150 int num_messages,
int timeout_millis)
158 if (r == ETIMEDOUT) {
171 int num_messages,
int timeout_millis)
179 if (r == ETIMEDOUT) {
202 if (r == ETIMEDOUT) {
214 while (!cmp_cb(sink->
messages[start], data)) {
219 &sink->
lock, &deadline);
221 if (r == ETIMEDOUT) {
226 "Unexpected condition error: %s\n",
Structure that collects messages from a topic.
Asterisk main include file. File version handling, generic pbx functions.
#define ast_realloc(p, len)
A wrapper for realloc()
struct stasis_message ** messages
#define STASIS_MESSAGE_TYPE_INIT(name)
Boiler-plate messaging macro for initializing message types.
struct stasis_message_type * stasis_test_message_type(void)
Gets the type of messages created by stasis_test_message_create().
int stasis_message_sink_wait_for_count(struct stasis_message_sink *sink, int num_messages, int timeout_millis)
Wait for a sink's num_messages field to reach a certain level.
struct stasis_message_sink * stasis_message_sink_create(void)
Create a message sink.
#define STASIS_MESSAGE_TYPE_CLEANUP(name)
Boiler-plate messaging macro for cleaning up message types.
struct stasis_message_type * stasis_message_type(const struct stasis_message *msg)
Get the message type for a stasis_message.
static int load_module(void)
#define ast_cond_wait(cond, mutex)
#define ast_cond_init(cond, attr)
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
stasis_subscription_cb stasis_message_sink_cb(void)
Topic callback to receive messages.
#define ast_cond_signal(cond)
int stasis_message_sink_wait_for(struct stasis_message_sink *sink, int start, stasis_wait_cb cmp_cb, const void *data, int timeout_millis)
Wait for a message that matches the given criteria.
struct stasis_message * stasis_test_message_create(void)
Creates a test message.
#define SCOPED_MUTEX(varname, lock)
scoped lock specialization for mutexes
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
#define ao2_ref(o, delta)
#define ast_malloc(len)
A wrapper for malloc()
STASIS_MESSAGE_TYPE_DEFN(stasis_test_message_type)
static struct timespec make_deadline(int timeout_millis)
struct stasis_message * stasis_message_create(struct stasis_message_type *type, void *data)
Create a new message.
struct timeval ast_tvadd(struct timeval a, struct timeval b)
Returns the sum of two timevals a + b.
static void stasis_message_sink_dtor(void *obj)
#define ast_cond_destroy(cond)
#define ao2_alloc(data_size, destructor_fn)
void(* stasis_subscription_cb)(void *data, struct stasis_subscription *sub, struct stasis_message *message)
Callback function type for Stasis subscriptions.
int stasis_subscription_final_message(struct stasis_subscription *sub, struct stasis_message *msg)
Determine whether a message is the final message to be received on a subscription.
int stasis_message_sink_should_stay(struct stasis_message_sink *sink, int num_messages, int timeout_millis)
Ensures that no new messages are received.
Module has failed to load, may be in an inconsistent state.
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS|AST_MODFLAG_LOAD_ORDER, "HTTP Phone Provisioning",.support_level=AST_MODULE_SUPPORT_EXTENDED,.load=load_module,.unload=unload_module,.reload=reload,.load_pri=AST_MODPRI_CHANNEL_DEPEND,.requires="http",)
struct stasis_forward * sub
int(* stasis_wait_cb)(struct stasis_message *msg, const void *data)
struct stasis_message_type * stasis_subscription_change_type(void)
Gets the message type for subscription change notices.
static void message_sink_cb(void *data, struct stasis_subscription *sub, struct stasis_message *message)
Implementation of the stasis_message_sink_cb() callback.
static int unload_module(void)
#define ast_mutex_init(pmutex)
#define ast_mutex_destroy(a)
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
#define ast_cond_timedwait(cond, mutex, time)
Test infrastructure for dealing with Stasis.