Tor
0.4.7.0-alpha-dev
core
mainloop
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
**/
30
DELIV_NEVER
=0,
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
**/
42
DELIV_PROMPT
,
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
**/
52
DELIV_IMMEDIATE
,
53
}
deliv_strategy_t
;
54
55
int
tor_mainloop_connect_pubsub
(
struct
pubsub_builder_t
*builder);
56
void
tor_mainloop_connect_pubsub_events
(
void
);
57
int
tor_mainloop_set_delivery_strategy
(
const
char
*msg_channel_name,
58
deliv_strategy_t
strategy);
59
void
tor_mainloop_disconnect_pubsub
(
void
);
60
61
#endif
/* !defined(TOR_MAINLOOP_PUBSUB_H) */
tor_mainloop_connect_pubsub
int tor_mainloop_connect_pubsub(struct pubsub_builder_t *builder)
Definition:
mainloop_pubsub.c:60
tor_mainloop_connect_pubsub_events
void tor_mainloop_connect_pubsub_events(void)
Definition:
mainloop_pubsub.c:84
tor_mainloop_disconnect_pubsub
void tor_mainloop_disconnect_pubsub(void)
Definition:
mainloop_pubsub.c:167
tor_mainloop_set_delivery_strategy
int tor_mainloop_set_delivery_strategy(const char *msg_channel_name, deliv_strategy_t strategy)
Definition:
mainloop_pubsub.c:140
deliv_strategy_t
deliv_strategy_t
Definition:
mainloop_pubsub.h:22
DELIV_PROMPT
@ DELIV_PROMPT
Definition:
mainloop_pubsub.h:42
DELIV_IMMEDIATE
@ DELIV_IMMEDIATE
Definition:
mainloop_pubsub.h:52
DELIV_NEVER
@ DELIV_NEVER
Definition:
mainloop_pubsub.h:30
pubsub_builder_t
struct pubsub_builder_t pubsub_builder_t
Definition:
pubsub_build.h:28
Generated by
1.9.1