|
Home / Open source / Terimber 2.0
msg_user_connection Class Referenceimplements user connection - the input/output channel to the business logic world
More...
#include <msg_user.h>
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_connection * | connect (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.
Constructor & Destructor Documentation
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().
| msg_user_connection::~msg_user_connection |
( |
|
) |
[virtual] |
destructor
Definition at line 72 of file msg_user.cpp.
References _async_list, _async_map, msg_base::_communicator, _mtx_async_wait, _mtx_wait, base_list< T >::begin(), base_map< K, T, Pr, M >::begin(), list< T >::clear(), map< K, T, Pr, M >::clear(), msg_communicator::destroy_msg(), base_list< T >::end(), and base_map< K, T, Pr, M >::end().
Member Function Documentation
| void msg_user_connection::push_msg |
( |
msg_cpp * |
msg |
) |
[virtual] |
overrides pushing message to the queue to avoid the dead blocking situation
- Parameters:
-
Reimplemented from msg_connection.
Definition at line 148 of file msg_user.cpp.
References _async_list, _async_map, msg_base::_communicator, msg_cpp::_marker, _mtx_async_wait, _mtx_wait, msg_cpp::_type, threadpool::borrow_thread(), callbacks_thread_ident, msg_communicator::destroy_msg(), base_map< K, T, Pr, M >::end(), map< K, T, Pr, M >::erase(), base_map< K, T, Pr, M >::find(), msg_communicator::get_thread_manager(), list< T >::push_back(), msg_connection::push_msg(), stay_on_alert_time, timeouts_thread_ident, user_type_reply, and user_type_reply_async.
| bool msg_user_connection::send |
( |
bool |
copy, |
|
|
msg_cpp * |
msg, |
|
|
msg_cpp *& |
reply | |
|
) |
| | |
sends message synchronically
- Parameters:
-
| copy |
flag make a copy of input message |
| msg |
input message |
| reply |
reply pointer |
Definition at line 197 of file msg_user.cpp.
References conf_connection::_address, msg_base::_communicator, _error, msg_connection::_info, _mtx_wait, msg_cpp::_receiver, msg_communicator::comm_msg(), msg_communicator::construct_msg(), msg_communicator::copy_msg(), smart_pointer< C >::detach(), msg_cpp::get_body(), msg_communicator::get_event_pool(), base_string< T >::length(), MSG_ERROR_ID, MSG_PRIORITY_HIGH, MSG_PRIORITY_NORMAL, msg_t::msgid, null_uuid, msg_t::priority, msg_t::timeout, user_type_send, uuid_gen(), and exception::what().
Referenced by aiomsg::send().
| guid_t msg_user_connection::send_async |
( |
bool |
copy, |
|
|
msg_cpp * |
msg | |
|
) |
| | |
sends message asynchronousally
- Parameters:
-
| copy |
flag make a copy of input message |
| msg |
input message |
Definition at line 307 of file msg_user.cpp.
References conf_connection::_address, _async_map, msg_base::_communicator, _error, msg_connection::_info, _mtx_async_wait, msg_cpp::_receiver, msg_communicator::comm_msg(), msg_communicator::copy_msg(), smart_pointer< C >::detach(), map< K, T, Pr, M >::insert(), MSG_PRIORITY_HIGH, MSG_PRIORITY_NORMAL, msg_t::msgid, null_uuid, msg_t::priority, msg_t::timeout, user_type_send_async, uuid_gen(), and exception::what().
Referenced by aiomsg::send_async().
| bool msg_user_connection::post |
( |
bool |
copy, |
|
|
msg_cpp * |
msg | |
|
) |
| | |
posts message
- Parameters:
-
| copy |
flag make a copy of input message |
| msg |
input message |
Definition at line 369 of file msg_user.cpp.
References conf_connection::_address, msg_base::_communicator, _error, msg_connection::_info, msg_cpp::_receiver, msg_communicator::comm_msg(), msg_communicator::copy_msg(), smart_pointer< C >::detach(), MSG_PRIORITY_HIGH, MSG_PRIORITY_NORMAL, msg_t::msgid, null_uuid, msg_t::priority, user_type_post, and exception::what().
Referenced by aiomsg::post().
| const char* msg_user_connection::get_last_error |
( |
|
) |
const [inline] |
| bool msg_user_connection::peek_async |
( |
|
) |
const [inline, protected] |
| bool msg_user_connection::pop_async |
( |
msg_cpp *& |
msg, |
|
|
guid_t & |
ident | |
|
) |
| | [protected] |
| bool msg_user_connection::peek_async |
( |
|
) |
[protected] |
| 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] |
| void msg_user_connection::v_do_job |
( |
size_t |
ident, |
|
|
void * |
user_data | |
|
) |
| | [protected, virtual] |
does the job
- Parameters:
-
| ident |
thread ident |
| user_data |
user defined data |
Implements terimber_thread_employer.
Definition at line 436 of file msg_user.cpp.
References conf_connection::_address, _callback, msg_base::_communicator, msg_connection::_info, msg_callback_notify::async_callback(), callbacks_thread_ident, smart_pointer< C >::detach(), msg_pack::make_error_msg(), pop_async(), pop_async_timeouted(), process_income_message(), queue_thread_ident, s_err_text, and timeouts_thread_ident.
| void msg_user_connection::wakeup |
( |
|
) |
[protected, virtual] |
| void msg_user_connection::v_off |
( |
|
) |
[protected, virtual] |
| void msg_user_connection::process_income_message |
( |
|
) |
[private] |
processes incoming messages
Definition at line 495 of file msg_user.cpp.
References _additional_threads, _callback, msg_base::_communicator, msg_cpp::_sender, threadpool::borrow_from_range(), threadpool::borrow_thread(), msg_communicator::comm_msg(), msg_communicator::construct_msg(), smart_pointer< C >::detach(), msg_communicator::get_thread_manager(), msg_callback_notify::incoming_callback(), msg_pack::make_reply_msg(), msg_queue< 3 >::peek(), msg_queue< 3 >::pop(), queue_thread_ident, stay_on_alert_time, user_type_post, user_type_send, and user_type_send_async.
Referenced by v_do_job().
Member Data Documentation
The documentation for this class was generated from the following files:
|
|