Tor  0.4.7.0-alpha-dev
mainloop_pubsub.h
Go to the documentation of this file.
1 /* Copyright (c) 2001, Matej Pfajfar.
2  * Copyright (c) 2001-2004, Roger Dingledine.
3  * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
4  * Copyright (c) 2007-2021, The Tor Project, Inc. */
5 /* See LICENSE for licensing information */
6 
7 /**
8  * @file mainloop_pubsub.h
9  * @brief Header for mainloop_pubsub.c
10  **/
11 
12 #ifndef TOR_MAINLOOP_PUBSUB_H
13 #define TOR_MAINLOOP_PUBSUB_H
14 
15 struct pubsub_builder_t;
16 
17 /**
18  * Describe when and how messages are delivered on message channel.
19  *
20  * Every message channel must be associated with one of these strategies.
21  **/
22 typedef enum {
23  /**
24  * Never deliver messages automatically.
25  *
26  * If a message channel uses this strategy, then no matter now many
27  * messages are published on it, they are not delivered until something
28  * manually calls dispatch_flush() for that channel
29  **/
31  /**
32  * Deliver messages promptly, via the event loop.
33  *
34  * If a message channel uses this strategy, then publishing a messages
35  * that channel activates an event that causes messages to be handled
36  * later in the mainloop. The messages will be processed at some point
37  * very soon, delaying only for pending IO events and the like.
38  *
39  * Generally this is the best choice for a delivery strategy, since
40  * it avoids stack explosion.
41  **/
43  /**
44  * Deliver messages immediately, skipping the event loop.
45  *
46  * Every event on this channel is flushed immediately after it is queued,
47  * using the stack.
48  *
49  * This delivery type should be used with caution, since it can cause
50  * unexpected call chains, resource starvation, and the like.
51  **/
54 
57 int tor_mainloop_set_delivery_strategy(const char *msg_channel_name,
58  deliv_strategy_t strategy);
60 
61 #endif /* !defined(TOR_MAINLOOP_PUBSUB_H) */
int tor_mainloop_connect_pubsub(struct pubsub_builder_t *builder)
void tor_mainloop_connect_pubsub_events(void)
void tor_mainloop_disconnect_pubsub(void)
int tor_mainloop_set_delivery_strategy(const char *msg_channel_name, deliv_strategy_t strategy)
deliv_strategy_t
@ DELIV_PROMPT
@ DELIV_IMMEDIATE
@ DELIV_NEVER
struct pubsub_builder_t pubsub_builder_t
Definition: pubsub_build.h:28