diff options
author | jcej <jcej@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-02-14 19:29:11 +0000 |
---|---|---|
committer | jcej <jcej@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-02-14 19:29:11 +0000 |
commit | 2e223ec826333dcedd350bd3df4f7a7e1e9161f2 (patch) | |
tree | 893c8b286dfae9b29b34d22dfd256a95ee2fcf8f /docs/tutorials/015/Protocol_Task.cpp | |
parent | 33864ee7505873b3bc93d5d40b9aad7fc17d4888 (diff) | |
download | ATCD-2e223ec826333dcedd350bd3df4f7a7e1e9161f2.tar.gz |
*** empty log message ***
Diffstat (limited to 'docs/tutorials/015/Protocol_Task.cpp')
-rw-r--r-- | docs/tutorials/015/Protocol_Task.cpp | 85 |
1 files changed, 6 insertions, 79 deletions
diff --git a/docs/tutorials/015/Protocol_Task.cpp b/docs/tutorials/015/Protocol_Task.cpp index 3cfe7495539..b1eb82a43ad 100644 --- a/docs/tutorials/015/Protocol_Task.cpp +++ b/docs/tutorials/015/Protocol_Task.cpp @@ -4,113 +4,40 @@ #include "Protocol_Task.h" // Construct the object and remember the thread count. -Protocol_Task::Protocol_Task( int _thr_count ) - : desired_thr_count_(_thr_count) +Protocol_Task::Protocol_Task(void) { + ; } Protocol_Task::~Protocol_Task(void) { + ; } -// Activate the object if necessary. int Protocol_Task::open(void *arg) { ACE_UNUSED_ARG(arg); - if( desired_thr_count_ ) - { - return this->activate(THR_NEW_LWP, desired_thr_count_); - } - return(0); } -/* When we're being closed by the ACE_Stream and we've got threads to - worry about then we drop a hangup message onto the message queue so - that svc() will go away. Except for the call to is_active(), this - is lifted directly from Tutorial 14. -*/ int Protocol_Task::close(u_long flags) { - if (flags == 1 && is_active() ) - { - ACE_Message_Block *hangupBlock = new ACE_Message_Block(); - - hangupBlock->msg_type(ACE_Message_Block::MB_HANGUP); - - if (this->putq(hangupBlock->duplicate()) == -1) { - ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "Task::close() putq"), -1); - } - - hangupBlock->release(); - - return this->wait(); - } - return 0; } -/* The put() method has to make a decision. If we've got threads then - put the unit of work onto the message queue for svc() to deal - with. If not then process() it directly. +/* When a message is put() onto the task, it's time to process() some data. */ int Protocol_Task::put(ACE_Message_Block *message,ACE_Time_Value *timeout) { - if( is_active() ) - { - return this->putq(message,timeout); - } - return this->process(message,timeout); } -/* svc() is about what you would expect. This is again lifted - directly from Tutorial 14 but with a call to process() for handling - the logic instead of doing the work right here. +/* Return an error since we don't want the task to ever be activated. */ int Protocol_Task::svc(void) { - ACE_Message_Block * message; - - while (1) - { - // Get a message - if ( this->getq(message, 0) == -1) { - ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "Protocol_Task::svc() getq"), -1); - } - - ACE_DEBUG ((LM_DEBUG, "(%P|%t) Protocol_Task::svc() got message\n")); - - // Check for hangup - if (message->msg_type() == ACE_Message_Block::MB_HANGUP) { - - ACE_DEBUG ((LM_DEBUG, "(%P|%t) Protocol_Task::svc() -- HANGUP block received\n")); - - // Hangup our thread-pool peers (if any) - if (this->putq(message->duplicate()) == -1) { - ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "Protocol_Task::svc() putq"), -1); - } - - // Leave svc() - break; - } - - // Do some work on the data. - if( this->process(message->duplicate(),0) == -1 ) - { - break; - } - - // Give up the message block before we go get another. - message->release(); - } - - // Give up the message block that caused us to exit the - // while(1) loop. - message->release(); - - return(0); + return -1; } /* There's nothing really magic about process(). We just decide if |