Thread portable class


Gate portable class


Timer class


Pool class


Terimber 2.0


About C++


Downloads Products & Services Support Clients Open Source About



Home / Open source / Terimber 2.0

msg_user_connection Class Reference

implements user connection - the input/output channel to the business logic world More...

#include <msg_user.h>

Inheritance diagram for msg_user_connection:

msg_connection msg_queue_processor msg_base msg_queue< 3 > terimber_thread_employer

List of all members.

Public Member Functions

 msg_user_connection (msg_communicator *communicator, msg_callback_notify *callback, const conf_connection &info, size_t additional_threads=0)
 constructor
virtual ~msg_user_connection ()
 destructor
virtual void push_msg (msg_cpp *msg)
 overrides pushing message to the queue to avoid the dead blocking situation
bool send (bool copy, msg_cpp *msg, msg_cpp *&reply)
 sends message synchronically
guid_t send_async (bool copy, msg_cpp *msg)
 sends message asynchronousally
bool post (bool copy, msg_cpp *msg)
 posts message
const char * get_last_error () const
 returns the last error

Static Public Member Functions

static msg_user_connectionconnect (msg_communicator *communicator, msg_callback_notify *callback, const conf_connection &info, size_t additional_threads)
 establishes the user type connection

Protected Member Functions

bool peek_async () const
 picks asynchronous wait list
bool pop_async (msg_cpp *&msg, guid_t &ident)
 pops the top message from asynchronous wait list
bool peek_async ()
 checks if there is asynchronous reply
bool pop_async_timeouted (guid_t &ident)
 removes timeouted asynchronous replies
bool peek_async_timeouted ()
 checks if there is asynchronous tiemouted reply
virtual void ping_notify ()
 inserts ping message
virtual bool v_has_job (size_t ident, void *user_data)
 check job
virtual void v_do_job (size_t ident, void *user_data)
 does the job
virtual void wakeup ()
 overrides the base functionality
virtual void v_off ()
 action on turning off

Private Types

typedef map< guid_t,
msg_wait_reply
reply_map_t
 maps guid to synchronous replies
typedef map< guid_t,
msg_wait_async_reply
reply_async_map_t
 maps guid to asynchronous replies
typedef list
< msg_wait_async_reply
reply_async_list_t
 list of received asynchronous replies

Private Member Functions

void process_income_message ()
 processes incoming messages

Private Attributes

string_t _error
 last error description
msg_callback_notify_callback
 user callback function
mutex _mtx_wait
 mutex for waiting list
mutex _mtx_async_wait
 mutex for asynchronous waiting list
reply_map_t _map
 map: marker -> wait reply object
reply_async_map_t _async_map
 map: marker -> async wait reply object
reply_async_list_t _async_list
size_t _additional_threads
 when async reply incoming the waiting object is moved from the map to the list


Detailed Description

implements user connection - the input/output channel to the business logic world

Definition at line 144 of file msg_user.h.


Member Typedef Documentation

maps guid to synchronous replies

Definition at line 149 of file msg_user.h.

maps guid to asynchronous replies

Definition at line 152 of file msg_user.h.

list of received asynchronous replies

Definition at line 155 of file msg_user.h.


Constructor & Destructor Documentation

msg_user_connection::msg_user_connection ( msg_communicator communicator,
msg_callback_notify callback,
const conf_connection info,
size_t  additional_threads = 0 
)

constructor

Parameters:
communicator  communicator pointer
callback  user callback
info  connection info
additional_threads  additional threads

Definition at line 65 of file msg_user.cpp.

Referenced by connect().


Member Function Documentation

msg_user_connection * msg_user_connection::connect ( msg_communicator communicator,
msg_callback_notify callback,
const conf_connection info,
size_t  additional_threads 
) [static]

establishes the user type connection

Parameters:
communicator  communicator pointer
callback  user callback
info  connection info
additional_threads  additional threads

Definition at line 606 of file msg_user.cpp.

References msg_connection::_state, msg_communicator::add_connection(), msg_connection::CONN_STATE_CONNECTED, and msg_user_connection().

Referenced by aiomsg::start().

bool msg_user_connection::post ( bool  copy,
msg_cpp msg 
)

const char* msg_user_connection::get_last_error (  )  const [inline]

returns the last error

Definition at line 198 of file msg_user.h.

References _error.

Referenced by aiomsg::post(), aiomsg::send(), and aiomsg::send_async().

bool msg_user_connection::peek_async (  )  const [inline, protected]

picks asynchronous wait list

Definition at line 206 of file msg_user.h.

References _async_list, _mtx_async_wait, and base_list< T >::empty().

Referenced by v_has_job().

bool msg_user_connection::pop_async ( msg_cpp *&  msg,
guid_t ident 
) [protected]

pops the top message from asynchronous wait list

Parameters:
msg  [out] message pointer
ident  [out] message ident

Definition at line 560 of file msg_user.cpp.

References _async_list, _mtx_async_wait, base_list< T >::empty(), base_list< T >::front(), msg_wait_async_reply::get_reply_data(), and list< T >::pop_front().

Referenced by v_do_job().

bool msg_user_connection::peek_async (  )  [protected]

checks if there is asynchronous reply

Definition at line 570 of file msg_user.cpp.

References _async_list, _mtx_async_wait, and base_list< T >::empty().

bool msg_user_connection::pop_async_timeouted ( guid_t ident  )  [protected]

removes timeouted asynchronous replies

Parameters:
ident  [out] message ident

Definition at line 577 of file msg_user.cpp.

References _async_map, _mtx_async_wait, base_map< K, T, Pr, M >::begin(), base_map< K, T, Pr, M >::end(), and map< K, T, Pr, M >::erase().

Referenced by v_do_job().

bool msg_user_connection::peek_async_timeouted (  )  [protected]

checks if there is asynchronous tiemouted reply

Definition at line 593 of file msg_user.cpp.

References _async_map, _mtx_async_wait, base_map< K, T, Pr, M >::begin(), and base_map< K, T, Pr, M >::end().

Referenced by ping_notify(), and v_has_job().

void msg_user_connection::ping_notify (  )  [protected, virtual]

bool msg_user_connection::v_has_job ( size_t  ident,
void *  user_data 
) [protected, virtual]

check job

overrides the base functionality

Parameters:
ident  thread ident
user_data  user defined data

Reimplemented from msg_queue_processor.

Definition at line 418 of file msg_user.cpp.

References callbacks_thread_ident, msg_base::is_on(), peek_async(), peek_async_timeouted(), queue_thread_ident, timeouts_thread_ident, and msg_queue_processor::v_has_job().

void msg_user_connection::v_do_job ( size_t  ident,
void *  user_data 
) [protected, virtual]

void msg_user_connection::wakeup (  )  [protected, virtual]

void msg_user_connection::v_off (  )  [protected, virtual]

action on turning off

Reimplemented from msg_queue_processor.

Definition at line 131 of file msg_user.cpp.

References msg_base::_communicator, _mtx_wait, msg_communicator::destroy_msg(), and msg_queue_processor::v_off().


Member Data Documentation

last error description

Definition at line 259 of file msg_user.h.

Referenced by get_last_error(), post(), send(), and send_async().

user callback function

Definition at line 260 of file msg_user.h.

Referenced by process_income_message(), and v_do_job().

mutex for waiting list

Definition at line 261 of file msg_user.h.

Referenced by push_msg(), send(), v_off(), and ~msg_user_connection().

map: marker -> wait reply object

Definition at line 263 of file msg_user.h.

map: marker -> async wait reply object

Definition at line 264 of file msg_user.h.

Referenced by peek_async_timeouted(), pop_async_timeouted(), push_msg(), send_async(), and ~msg_user_connection().

list: async wait reply objects

Definition at line 265 of file msg_user.h.

Referenced by peek_async(), pop_async(), push_msg(), and ~msg_user_connection().

when async reply incoming the waiting object is moved from the map to the list

Definition at line 267 of file msg_user.h.

Referenced by process_income_message(), and wakeup().


The documentation for this class was generated from the following files:


© Copyright Terimber 2003-.