Tor
0.4.7.0-alpha-dev
|
Connect the publish-subscribe code to the main-loop. More...
#include "orconfig.h"
#include "core/or/or.h"
#include "core/mainloop/mainloop.h"
#include "core/mainloop/mainloop_pubsub.h"
#include "lib/container/smartlist.h"
#include "lib/dispatch/dispatch.h"
#include "lib/dispatch/dispatch_naming.h"
#include "lib/evloop/compat_libevent.h"
#include "lib/pubsub/pubsub.h"
#include "lib/pubsub/pubsub_build.h"
Go to the source code of this file.
Functions | |
static void | flush_channel_event (mainloop_event_t *ev, void *arg) |
int | tor_mainloop_connect_pubsub (struct pubsub_builder_t *builder) |
void | tor_mainloop_connect_pubsub_events (void) |
static void | alertfn_never (dispatch_t *d, channel_id_t chan, void *arg) |
static void | alertfn_prompt (dispatch_t *d, channel_id_t chan, void *arg) |
static void | alertfn_immediate (dispatch_t *d, channel_id_t chan, void *arg) |
int | tor_mainloop_set_delivery_strategy (const char *msg_channel_name, deliv_strategy_t strategy) |
void | tor_mainloop_disconnect_pubsub (void) |
Variables | |
static dispatch_t * | the_dispatcher = NULL |
static pubsub_items_t * | the_pubsub_items = NULL |
static smartlist_t * | alert_events = NULL |
Connect the publish-subscribe code to the main-loop.
This module is responsible for instantiating all the channels used by the publish-subscribe code, and making sure that each one's messages are processed when appropriate.
Definition in file mainloop_pubsub.c.
|
static |
Dispatch alertfn callback: flush all messages right now. Implements DELIV_IMMEDIATE.
Definition at line 127 of file mainloop_pubsub.c.
|
static |
Dispatch alertfn callback: do nothing. Implements DELIV_NEVER.
Definition at line 102 of file mainloop_pubsub.c.
|
static |
Dispatch alertfn callback: activate a mainloop event. Implements DELIV_PROMPT.
Definition at line 114 of file mainloop_pubsub.c.
|
static |
Mainloop event callback: flush all the messages in a channel.
The channel is encoded as a pointer, and passed via arg.
Definition at line 46 of file mainloop_pubsub.c.
Referenced by tor_mainloop_connect_pubsub_events().
int tor_mainloop_connect_pubsub | ( | struct pubsub_builder_t * | builder | ) |
Construct our global pubsub object from builder. Return 0 on success, -1 on failure.
Definition at line 60 of file mainloop_pubsub.c.
Referenced by pubsub_install().
void tor_mainloop_connect_pubsub_events | ( | void | ) |
Install libevent events for all of the pubsub channels.
Invoke this after tor_mainloop_connect_pubsub, and after libevent has been initialized.
Definition at line 84 of file mainloop_pubsub.c.
Referenced by pubsub_connect().
void tor_mainloop_disconnect_pubsub | ( | void | ) |
Remove all pubsub dispatchers and events from the mainloop.
Definition at line 167 of file mainloop_pubsub.c.
Referenced by tor_mainloop_connect_pubsub().
int tor_mainloop_set_delivery_strategy | ( | const char * | msg_channel_name, |
deliv_strategy_t | strategy | ||
) |
Set the strategy to be used for delivering messages on the named channel.
This function needs to be called once globally for each channel, to set up how messages are delivered.
Definition at line 140 of file mainloop_pubsub.c.
Referenced by pubsub_connect().
|
static |
A list of mainloop_event_t, indexed by channel ID, to flush the messages on a channel.
Definition at line 38 of file mainloop_pubsub.c.
Referenced by tor_mainloop_connect_pubsub_events().
|
static |
Dispatcher to use for delivering messages.
Definition at line 32 of file mainloop_pubsub.c.
Referenced by flush_channel_event(), tor_mainloop_connect_pubsub(), and tor_mainloop_connect_pubsub_events().