libzmq  master
ZeroMQ C++ Core Engine (LIBZMQ)
zmq::ctx_t Class Reference

#include <ctx.hpp>

Collaboration diagram for zmq::ctx_t:

Classes

struct  pending_connection_t
 

Public Types

enum  { term_tid = 0, reaper_tid = 1 }
 

Public Member Functions

 ctx_t ()
 
 ~ctx_t ()
 
bool check_tag ()
 
zmq::io_thread_tchoose_io_thread (uint64_t affinity_)
 
void connect_pending (const char *addr_, zmq::socket_base_t *bind_socket_)
 
zmq::socket_base_tcreate_socket (int type_)
 
void destroy_socket (zmq::socket_base_t *socket_)
 
endpoint_t find_endpoint (const char *addr_)
 
int get (int option_)
 
zmq::object_tget_reaper ()
 
void pend_connection (const std::string &addr_, const endpoint_t &endpoint_, pipe_t **pipes_)
 
int register_endpoint (const char *addr_, const endpoint_t &endpoint_)
 
void send_command (uint32_t tid_, const command_t &command_)
 
int set (int option_, int optval_)
 
int shutdown ()
 
void start_thread (thread_t &thread_, thread_fn *tfn_, void *arg_) const
 
int terminate ()
 
int unregister_endpoint (const std::string &addr_, socket_base_t *socket_)
 
void unregister_endpoints (zmq::socket_base_t *socket_)
 

Private Types

typedef std::vector< uint32_t > empty_slots_t
 
typedef std::map< std::string, endpoint_tendpoints_t
 
typedef std::vector< zmq::io_thread_t * > io_threads_t
 
typedef std::multimap< std::string, pending_connection_tpending_connections_t
 
enum  side { connect_side, bind_side }
 
typedef array_t< socket_base_tsockets_t
 

Private Member Functions

 ctx_t (const ctx_t &)
 
void connect_inproc_sockets (zmq::socket_base_t *bind_socket_, options_t &bind_options, const pending_connection_t &pending_connection_, side side_)
 
const ctx_toperator= (const ctx_t &)
 

Private Attributes

bool blocky
 
mutex_t crypto_sync
 
empty_slots_t empty_slots
 
endpoints_t endpoints
 
mutex_t endpoints_sync
 
int io_thread_count
 
io_threads_t io_threads
 
bool ipv6
 
int max_msgsz
 
int max_sockets
 
mutex_t opt_sync
 
pending_connections_t pending_connections
 
zmq::reaper_treaper
 
uint32_t slot_count
 
mutex_t slot_sync
 
i_mailbox ** slots
 
sockets_t sockets
 
bool starting
 
uint32_t tag
 
mailbox_t term_mailbox
 
bool terminating
 
int thread_priority
 
int thread_sched_policy
 

Static Private Attributes

static atomic_counter_t max_socket_id
 

Detailed Description

Definition at line 68 of file ctx.hpp.

Member Typedef Documentation

typedef std::vector<uint32_t> zmq::ctx_t::empty_slots_t
private

Definition at line 155 of file ctx.hpp.

typedef std::map<std::string, endpoint_t> zmq::ctx_t::endpoints_t
private

Definition at line 186 of file ctx.hpp.

typedef std::vector<zmq::io_thread_t*> zmq::ctx_t::io_threads_t
private

Definition at line 175 of file ctx.hpp.

typedef std::multimap<std::string, pending_connection_t> zmq::ctx_t::pending_connections_t
private

Definition at line 190 of file ctx.hpp.

Definition at line 151 of file ctx.hpp.

Member Enumeration Documentation

anonymous enum
Enumerator
term_tid 
reaper_tid 

Definition at line 129 of file ctx.hpp.

enum zmq::ctx_t::side
private
Enumerator
connect_side 
bind_side 

Definition at line 228 of file ctx.hpp.

Constructor & Destructor Documentation

zmq::ctx_t::ctx_t ( )

Definition at line 74 of file ctx.cpp.

References crypto_sync, zmq::mutex_t::lock(), zmq::mutex_t::unlock(), and zmq_assert.

Here is the call graph for this function:

zmq::ctx_t::~ctx_t ( )

Definition at line 114 of file ctx.cpp.

References zmq::array_t< T, ID >::empty(), io_threads, LIBZMQ_DELETE, reaper, slots, sockets, tag, zmq_assert, and ZMQ_CTX_TAG_VALUE_BAD.

Here is the call graph for this function:

zmq::ctx_t::ctx_t ( const ctx_t )
private

Member Function Documentation

bool zmq::ctx_t::check_tag ( )

Definition at line 109 of file ctx.cpp.

References tag, and ZMQ_CTX_TAG_VALUE_GOOD.

zmq::io_thread_t * zmq::ctx_t::choose_io_thread ( uint64_t  affinity_)

Definition at line 433 of file ctx.cpp.

References io_threads.

Referenced by zmq::object_t::choose_io_thread().

Here is the caller graph for this function:

void zmq::ctx_t::connect_pending ( const char *  addr_,
zmq::socket_base_t bind_socket_ 
)

Definition at line 552 of file ctx.cpp.

References bind_side, connect_inproc_sockets(), endpoints, endpoints_sync, zmq::mutex_t::lock(), pending_connections, and zmq::mutex_t::unlock().

Referenced by zmq::object_t::connect_pending().

Here is the call graph for this function:

Here is the caller graph for this function:

void zmq::ctx_t::destroy_socket ( zmq::socket_base_t socket_)

Definition at line 397 of file ctx.cpp.

References zmq::array_t< T, ID >::empty(), empty_slots, zmq::array_t< T, ID >::erase(), zmq::object_t::get_tid(), zmq::mutex_t::lock(), reaper, slot_sync, slots, sockets, zmq::reaper_t::stop(), terminating, and zmq::mutex_t::unlock().

Referenced by zmq::object_t::destroy_socket().

Here is the call graph for this function:

Here is the caller graph for this function:

zmq::endpoint_t zmq::ctx_t::find_endpoint ( const char *  addr_)

Definition at line 508 of file ctx.cpp.

References ECONNREFUSED, endpoints, endpoints_sync, zmq::own_t::inc_seqnum(), zmq::mutex_t::lock(), zmq::endpoint_t::socket, and zmq::mutex_t::unlock().

Referenced by zmq::object_t::find_endpoint().

Here is the call graph for this function:

Here is the caller graph for this function:

int zmq::ctx_t::get ( int  option_)

Definition at line 293 of file ctx.cpp.

References blocky, clipped_maxsocket(), io_thread_count, ipv6, max_msgsz, max_sockets, ZMQ_BLOCKY, ZMQ_IO_THREADS, ZMQ_IPV6, ZMQ_MAX_MSGSZ, ZMQ_MAX_SOCKETS, and ZMQ_SOCKET_LIMIT.

Referenced by zmq::socket_base_t::socket_base_t().

Here is the call graph for this function:

Here is the caller graph for this function:

zmq::object_t * zmq::ctx_t::get_reaper ( )

Definition at line 417 of file ctx.cpp.

References reaper.

Referenced by zmq::object_t::send_reap(), and zmq::object_t::send_reaped().

Here is the caller graph for this function:

const ctx_t& zmq::ctx_t::operator= ( const ctx_t )
private
void zmq::ctx_t::pend_connection ( const std::string &  addr_,
const endpoint_t endpoint_,
pipe_t **  pipes_ 
)

Definition at line 531 of file ctx.cpp.

References connect_inproc_sockets(), connect_side, endpoints, endpoints_sync, zmq::own_t::inc_seqnum(), zmq::mutex_t::lock(), pending_connections, zmq::endpoint_t::socket, and zmq::mutex_t::unlock().

Referenced by zmq::object_t::pend_connection().

Here is the call graph for this function:

Here is the caller graph for this function:

int zmq::ctx_t::register_endpoint ( const char *  addr_,
const endpoint_t endpoint_ 
)

Definition at line 453 of file ctx.cpp.

References EADDRINUSE, endpoints, endpoints_sync, zmq::mutex_t::lock(), and zmq::mutex_t::unlock().

Referenced by zmq::object_t::register_endpoint().

Here is the call graph for this function:

Here is the caller graph for this function:

void zmq::ctx_t::send_command ( uint32_t  tid_,
const command_t command_ 
)

Definition at line 428 of file ctx.cpp.

References zmq::i_mailbox::send(), and slots.

Referenced by zmq::object_t::send_command(), zmq::object_t::send_done(), and zmq::object_t::send_stop().

Here is the call graph for this function:

Here is the caller graph for this function:

int zmq::ctx_t::shutdown ( )
void zmq::ctx_t::start_thread ( thread_t thread_,
thread_fn tfn_,
void *  arg_ 
) const

Definition at line 422 of file ctx.cpp.

References zmq::thread_t::setSchedulingParameters(), zmq::thread_t::start(), thread_priority, and thread_sched_policy.

Here is the call graph for this function:

int zmq::ctx_t::unregister_endpoint ( const std::string &  addr_,
socket_base_t socket_ 
)

Definition at line 470 of file ctx.cpp.

References endpoints, endpoints_sync, zmq::mutex_t::lock(), and zmq::mutex_t::unlock().

Referenced by zmq::object_t::unregister_endpoint().

Here is the call graph for this function:

Here is the caller graph for this function:

void zmq::ctx_t::unregister_endpoints ( zmq::socket_base_t socket_)

Definition at line 490 of file ctx.cpp.

References endpoints, endpoints_sync, zmq::mutex_t::lock(), and zmq::mutex_t::unlock().

Referenced by zmq::object_t::unregister_endpoints().

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

bool zmq::ctx_t::blocky
private

Definition at line 209 of file ctx.hpp.

Referenced by get(), and set().

mutex_t zmq::ctx_t::crypto_sync
private

Definition at line 237 of file ctx.hpp.

Referenced by ctx_t().

empty_slots_t zmq::ctx_t::empty_slots
private

Definition at line 156 of file ctx.hpp.

Referenced by create_socket(), and destroy_socket().

endpoints_t zmq::ctx_t::endpoints
private
mutex_t zmq::ctx_t::endpoints_sync
private
int zmq::ctx_t::io_thread_count
private

Definition at line 206 of file ctx.hpp.

Referenced by create_socket(), get(), and set().

io_threads_t zmq::ctx_t::io_threads
private

Definition at line 176 of file ctx.hpp.

Referenced by choose_io_thread(), create_socket(), and ~ctx_t().

bool zmq::ctx_t::ipv6
private

Definition at line 212 of file ctx.hpp.

Referenced by get(), and set().

int zmq::ctx_t::max_msgsz
private

Definition at line 203 of file ctx.hpp.

Referenced by get(), and set().

zmq::atomic_counter_t zmq::ctx_t::max_socket_id
staticprivate

Definition at line 197 of file ctx.hpp.

Referenced by connect_inproc_sockets(), and create_socket().

int zmq::ctx_t::max_sockets
private

Definition at line 200 of file ctx.hpp.

Referenced by create_socket(), get(), and set().

mutex_t zmq::ctx_t::opt_sync
private

Definition at line 219 of file ctx.hpp.

Referenced by create_socket(), and set().

pending_connections_t zmq::ctx_t::pending_connections
private

Definition at line 191 of file ctx.hpp.

Referenced by connect_pending(), pend_connection(), and terminate().

zmq::reaper_t* zmq::ctx_t::reaper
private

Definition at line 172 of file ctx.hpp.

Referenced by create_socket(), destroy_socket(), get_reaper(), shutdown(), terminate(), and ~ctx_t().

uint32_t zmq::ctx_t::slot_count
private

Definition at line 179 of file ctx.hpp.

Referenced by create_socket().

mutex_t zmq::ctx_t::slot_sync
private

Definition at line 169 of file ctx.hpp.

Referenced by create_socket(), destroy_socket(), shutdown(), and terminate().

i_mailbox** zmq::ctx_t::slots
private

Definition at line 180 of file ctx.hpp.

Referenced by create_socket(), destroy_socket(), send_command(), and ~ctx_t().

sockets_t zmq::ctx_t::sockets
private

Definition at line 152 of file ctx.hpp.

Referenced by create_socket(), destroy_socket(), shutdown(), terminate(), and ~ctx_t().

bool zmq::ctx_t::starting
private

Definition at line 160 of file ctx.hpp.

Referenced by create_socket(), shutdown(), and terminate().

uint32_t zmq::ctx_t::tag
private

Definition at line 146 of file ctx.hpp.

Referenced by check_tag(), and ~ctx_t().

mailbox_t zmq::ctx_t::term_mailbox
private

Definition at line 183 of file ctx.hpp.

Referenced by create_socket(), and terminate().

bool zmq::ctx_t::terminating
private

Definition at line 163 of file ctx.hpp.

Referenced by create_socket(), destroy_socket(), shutdown(), and terminate().

int zmq::ctx_t::thread_priority
private

Definition at line 215 of file ctx.hpp.

Referenced by set(), and start_thread().

int zmq::ctx_t::thread_sched_policy
private

Definition at line 216 of file ctx.hpp.

Referenced by set(), and start_thread().