version 1.5, 2002/03/21 16:10:00
|
version 1.6, 2002/03/21 22:53:10
|
|
|
_controller(controller), | _controller(controller), |
_name(name), | _name(name), |
_reference_count(1), | _reference_count(1), |
|
_shutting_down(0), |
_module_address(module_address) | _module_address(module_address) |
| |
{ | { |
|
|
| |
} | } |
| |
|
|
Boolean operator == (const module_rep *rep) const | Boolean operator == (const module_rep *rep) const |
{ | { |
if (rep == this ) | if (rep == this ) |
|
|
void *get_module_address(void) const { return _module_address; } | void *get_module_address(void) const { return _module_address; } |
Boolean module_receive_message(Message *msg) | Boolean module_receive_message(Message *msg) |
{ | { |
|
Boolean ret; |
_thread_safety.lock(pegasus_thread_self()); | _thread_safety.lock(pegasus_thread_self()); |
try { _receive_message(msg); } |
try { ret = _receive_message(msg); } |
catch(...) { _thread_safety.unlock(); throw; } | catch(...) { _thread_safety.unlock(); throw; } |
_thread_safety.unlock(); | _thread_safety.unlock(); |
|
return ret; |
} | } |
| |
void _send_async_callback(Uint32 msg_handle, Message *msg) | void _send_async_callback(Uint32 msg_handle, Message *msg) |
|
|
} | } |
void _send_shutdown_notify(Uint32 code) | void _send_shutdown_notify(Uint32 code) |
{ | { |
|
_thread_safety.lock(pegasus_thread_self()); |
|
if( _shutting_down == 0 ) |
|
{ |
|
_shutting_down++; |
_shutdown_notify(code); | _shutdown_notify(code); |
} | } |
|
_thread_safety.unlock(); |
|
} |
void lock(void) | void lock(void) |
{ | { |
_thread_safety.lock(pegasus_thread_self()); | _thread_safety.lock(pegasus_thread_self()); |
|
|
ModuleController *_controller; | ModuleController *_controller; |
String _name; | String _name; |
AtomicInt _reference_count; | AtomicInt _reference_count; |
|
Uint32 _shutting_down; |
|
|
void *_module_address; | void *_module_address; |
Boolean (*_receive_message)(Message *); | Boolean (*_receive_message)(Message *); |
void (*_async_callback)(Uint32, Message *); | void (*_async_callback)(Uint32, Message *); |
|
|
void (*async_callback)(Uint32, Message *), | void (*async_callback)(Uint32, Message *), |
void (*shutdown_notify)(Uint32 code)) ; | void (*shutdown_notify)(Uint32 code)) ; |
| |
virtual ~pegasus_module(void) |
~pegasus_module(void) |
{ | { |
_rep->dereference(); | _rep->dereference(); |
if( 0 == _rep->reference_count()) | if( 0 == _rep->reference_count()) |
|
|
| |
pegasus_module(void); | pegasus_module(void); |
pegasus_module(const pegasus_module & mod); | pegasus_module(const pegasus_module & mod); |
virtual Boolean _rcv_msg(Message *) ; |
Boolean _rcv_msg(Message *) ; |
Boolean _receive_message(Message *msg) | Boolean _receive_message(Message *msg) |
{ | { |
_rep->module_receive_message(msg); |
return _rep->module_receive_message(msg); |
} | } |
| |
void _send_async_callback(Uint32 msg_handle, Message *msg) | void _send_async_callback(Uint32 msg_handle, Message *msg) |
|
|
_rep->_send_shutdown_notify(code); | _rep->_send_shutdown_notify(code); |
} | } |
| |
virtual Boolean _shutdown(Uint32) ; |
Boolean _shutdown(Uint32 code) { _send_shutdown_notify(code); return true; } |
virtual void reference(void) { _rep->reference(); } |
|
virtual void dereference(void) { _rep->dereference(); } |
void reference(void) { _rep->reference(); } |
|
void dereference(void) { _rep->dereference(); } |
| |
friend class ModuleController; | friend class ModuleController; |
}; | }; |
|
|
public: | public: |
typedef MessageQueueService Base; | typedef MessageQueueService Base; |
| |
ModuleController(const char *name, Uint32 queueID); |
ModuleController(const char *name); |
|
ModuleController(const char *name, |
|
Sint16 min_threads, |
|
Sint16 max_threads, |
|
struct timeval & create_thread, |
|
struct timeval & destroy_thread, |
|
struct timeval & deadlock); |
|
|
|
|
virtual ~ModuleController(void); | virtual ~ModuleController(void); |
| |
// module api | // module api |
ModuleController & register_module(const String & module_name, | ModuleController & register_module(const String & module_name, |
void *module_address, | void *module_address, |
void (*async_callback)(Uint32, Message *)); |
Boolean (*receive_message)(Message *), |
|
void (*async_callback)(Uint32, Message *), |
|
void (*shutdown_notify)(Uint32)) throw(AlreadyExists); |
| |
Boolean deregister_module(const String & module_name); | Boolean deregister_module(const String & module_name); |
| |