Tor  0.4.7.0-alpha-dev
Enumerations | Functions
mainloop_pubsub.h File Reference

Header for mainloop_pubsub.c. More...

Go to the source code of this file.

Enumerations

enum  deliv_strategy_t { DELIV_NEVER =0 , DELIV_PROMPT , DELIV_IMMEDIATE }
 

Functions

int tor_mainloop_connect_pubsub (struct pubsub_builder_t *builder)
 
void tor_mainloop_connect_pubsub_events (void)
 
int tor_mainloop_set_delivery_strategy (const char *msg_channel_name, deliv_strategy_t strategy)
 
void tor_mainloop_disconnect_pubsub (void)
 

Detailed Description

Header for mainloop_pubsub.c.

Definition in file mainloop_pubsub.h.

Enumeration Type Documentation

◆ deliv_strategy_t

Describe when and how messages are delivered on message channel.

Every message channel must be associated with one of these strategies.

Enumerator
DELIV_NEVER 

Never deliver messages automatically.

If a message channel uses this strategy, then no matter now many messages are published on it, they are not delivered until something manually calls dispatch_flush() for that channel

DELIV_PROMPT 

Deliver messages promptly, via the event loop.

If a message channel uses this strategy, then publishing a messages that channel activates an event that causes messages to be handled later in the mainloop. The messages will be processed at some point very soon, delaying only for pending IO events and the like.

Generally this is the best choice for a delivery strategy, since it avoids stack explosion.

DELIV_IMMEDIATE 

Deliver messages immediately, skipping the event loop.

Every event on this channel is flushed immediately after it is queued, using the stack.

This delivery type should be used with caution, since it can cause unexpected call chains, resource starvation, and the like.

Definition at line 22 of file mainloop_pubsub.h.

Function Documentation

◆ tor_mainloop_connect_pubsub()

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().

◆ tor_mainloop_connect_pubsub_events()

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().

◆ tor_mainloop_disconnect_pubsub()

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().

◆ tor_mainloop_set_delivery_strategy()

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().