ACE_Stream_Head<> Class Template Reference

Standard task that acts as reader or writer at the head of an ACE_Stream. More...

#include <Stream_Modules.h>

Inheritance diagram for ACE_Stream_Head<>:

Inheritance graph
[legend]
Collaboration diagram for ACE_Stream_Head<>:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 ACE_Stream_Head (void)
 Construction.

 ~ACE_Stream_Head (void)
 Destruction.

virtual int open (void *a=0)
virtual int close (u_long flags=0)
virtual int put (ACE_Message_Block *msg, ACE_Time_Value *=0)
virtual int svc (void)
 Run by a daemon thread to handle deferred processing.

virtual int init (int argc, ACE_TCHAR *argv[])
 Initializes object when dynamic linking occurs.

virtual int info (ACE_TCHAR **info_string, size_t length) const
 Returns information on a service object.

virtual int fini (void)
 Terminates object when dynamic unlinking occurs.

void dump (void) const
 Dump the state of an object.


Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks.


Private Member Functions

int control (ACE_Message_Block *)
 Performs canonical flushing at the ACE_Stream Head.

int canonical_flush (ACE_Message_Block *)

Detailed Description

template<ACE_SYNCH_DECL>
class ACE_Stream_Head<>

Standard task that acts as reader or writer at the head of an ACE_Stream.

A ACE_Message_Block sent to this task (via its put() hook) triggers actions depending on the block type and whether the task is acting as a reader or a writer. If the block is of type ACE_Message_Block::MB_IOCTL, the block's is assumed to contain (beginning at its rd_ptr()) an ACE_IO_Cntl_Msg object and is processed accordingly. This is usually used to set the task's message queue high water and/or low water marks.

When the block is not ACE_Message_Block::MB_IOCTL, processing depends on the ACE_Stream_Head's role in the module:

Definition at line 51 of file Stream_Modules.h.


Constructor & Destructor Documentation

template<ACE_SYNCH_DECL >
ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_Stream_Head<>::ACE_Stream_Head void   ) 
 

Construction.

Definition at line 19 of file Stream_Modules.cpp.

References ACE_TRACE.

00020 {
00021   ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE>::ACE_Stream_Head");
00022 }

template<ACE_SYNCH_DECL >
ACE_Stream_Head<>::~ACE_Stream_Head void   ) 
 

Destruction.

Definition at line 25 of file Stream_Modules.cpp.

References ACE_TRACE.

00026 {
00027   ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE>::~ACE_Stream_Head");
00028 }


Member Function Documentation

template<ACE_SYNCH_DECL >
int ACE_Stream_Head<>::canonical_flush ACE_Message_Block  )  [private]
 

Definition at line 84 of file Stream_Modules.cpp.

References ACE_BIT_ENABLED, ACE_CLR_BITS, ACE_TRACE, ACE_Task< ACE_SYNCH_USE >::flush(), ACE_Message_Block::rd_ptr(), ACE_Message_Block::release(), and ACE_Task< ACE_SYNCH_USE >::reply().

Referenced by ACE_Stream_Head<>::put().

00085 {
00086   ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE>::canonical_flush");
00087   char *cp = mb->rd_ptr ();
00088 
00089   if (ACE_BIT_ENABLED (*cp, ACE_Task_Flags::ACE_FLUSHR))
00090     {
00091       this->flush (ACE_Task_Flags::ACE_FLUSHALL);
00092       ACE_CLR_BITS (*cp, ACE_Task_Flags::ACE_FLUSHR);
00093     }
00094 
00095   if (ACE_BIT_ENABLED (*cp, ACE_Task_Flags::ACE_FLUSHW))
00096     return this->reply (mb);
00097   else
00098     mb->release ();
00099   return 0;
00100 }

template<ACE_SYNCH_DECL >
int ACE_Stream_Head<>::close u_long  flags = 0  )  [virtual]
 

Hook called from ACE_Thread_Exit when during thread exit and from the default implementation of . In general, this method shouldn't be called directly by an application, particularly if the is running as an Active Object. Instead, a special message should be passed into the via the method defined below, and the method should interpret this as a flag to shut down the .

Reimplemented from ACE_Task_Base.

Definition at line 48 of file Stream_Modules.cpp.

References ACE_TRACE.

00049 {
00050   ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE>::close");
00051   return 0;
00052 }

template<ACE_SYNCH_DECL >
int ACE_Stream_Head<>::control ACE_Message_Block  )  [private]
 

Performs canonical flushing at the ACE_Stream Head.

Definition at line 62 of file Stream_Modules.cpp.

References ACE_IO_Cntl_Msg::ACE_IO_Cntl_Cmds, ACE_TRACE, ACE_IO_Cntl_Msg::cmd(), ACE_Message_Block::cont(), ACE_Message_Block::rd_ptr(), ACE_IO_Cntl_Msg::rval(), and ACE_Task< ACE_SYNCH_USE >::water_marks().

Referenced by ACE_Stream_Head<>::put().

00063 {
00064   ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE>::control");
00065   ACE_IO_Cntl_Msg *ioc = (ACE_IO_Cntl_Msg *) mb->rd_ptr ();
00066   ACE_IO_Cntl_Msg::ACE_IO_Cntl_Cmds cmd;
00067 
00068   switch (cmd = ioc->cmd ())
00069     {
00070     case ACE_IO_Cntl_Msg::SET_LWM:
00071     case ACE_IO_Cntl_Msg::SET_HWM:
00072       this->water_marks (cmd, *(size_t *) mb->cont ()->rd_ptr ());
00073       ioc->rval (0);
00074       break;
00075     default:
00076       return 0;
00077     }
00078   return ioc->rval ();
00079 }

template<ACE_SYNCH_DECL >
void ACE_Stream_Head<>::dump void   )  const
 

Dump the state of an object.

Reimplemented from ACE_Task< ACE_SYNCH_USE >.

Definition at line 31 of file Stream_Modules.cpp.

References ACE_TRACE.

00032 {
00033 #if defined (ACE_HAS_DUMP)
00034   ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE>::dump");
00035 #endif /* ACE_HAS_DUMP */
00036 }

template<ACE_SYNCH_DECL >
int ACE_Stream_Head<>::fini void   )  [virtual]
 

Terminates object when dynamic unlinking occurs.

Reimplemented from ACE_Shared_Object.

Definition at line 150 of file Stream_Modules.cpp.

References ACE_TRACE.

00151 {
00152   ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE>::fini");
00153   return 0;
00154 }

template<ACE_SYNCH_DECL >
int ACE_Stream_Head<>::info ACE_TCHAR **  info_string,
size_t  length
const [virtual]
 

Returns information on a service object.

Reimplemented from ACE_Shared_Object.

Definition at line 137 of file Stream_Modules.cpp.

References ACE_TCHAR, ACE_TRACE, ACE_Task< ACE_SYNCH_USE >::name(), ACE_OS::strdup(), ACE_OS::strlen(), and ACE_OS::strsncpy().

00138 {
00139   ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE>::info");
00140   const ACE_TCHAR *name = this->name ();
00141 
00142   if (*strp == 0 && (*strp = ACE_OS::strdup (name)) == 0)
00143     return -1;
00144   else
00145     ACE_OS::strsncpy (*strp, name, length);
00146   return static_cast<int> (ACE_OS::strlen (name));
00147 }

template<ACE_SYNCH_DECL >
int ACE_Stream_Head<>::init int  argc,
ACE_TCHAR argv[]
[virtual]
 

Initializes object when dynamic linking occurs.

Reimplemented from ACE_Shared_Object.

Definition at line 130 of file Stream_Modules.cpp.

References ACE_TCHAR, and ACE_TRACE.

00131 {
00132   ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE>::init");
00133   return 0;
00134 }

template<ACE_SYNCH_DECL >
int ACE_Stream_Head<>::open void *  a = 0  )  [virtual]
 

Hook called to initialize a task and prepare it for execution. args can be used to pass arbitrary information into .

Reimplemented from ACE_Task_Base.

Definition at line 41 of file Stream_Modules.cpp.

References ACE_TRACE.

00042 {
00043   ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE>::open");
00044   return 0;
00045 }

template<ACE_SYNCH_DECL >
int ACE_Stream_Head<>::put ACE_Message_Block msg,
ACE_Time_Value = 0
[virtual]
 

A hook method that can be used to pass a message to a task, where it can be processed immediately or queued for subsequent processing in the hook method.

Reimplemented from ACE_Task_Base.

Definition at line 103 of file Stream_Modules.cpp.

References ACE_TRACE, ACE_Stream_Head<>::canonical_flush(), ACE_Stream_Head<>::control(), ACE_Task_Base::is_writer(), ACE_Message_Block::msg_type(), ACE_Task< ACE_SYNCH_USE >::put_next(), and ACE_Task< ACE_SYNCH_USE >::putq().

00105 {
00106   ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE>::put");
00107   int res = 0;
00108 
00109   if (mb->msg_type () == ACE_Message_Block::MB_IOCTL
00110       && (res = this->control (mb)) == -1)
00111     return res;
00112 
00113   if (this->is_writer ())
00114     return this->put_next (mb, tv);
00115   else // this->is_reader ()
00116     {
00117       switch (mb->msg_type ())
00118         {
00119         case ACE_Message_Block::MB_FLUSH:
00120           return this->canonical_flush (mb);
00121         default:
00122           break;
00123         }
00124 
00125       return this->putq (mb, tv);
00126     }
00127 }

template<ACE_SYNCH_DECL >
int ACE_Stream_Head<>::svc void   )  [virtual]
 

Run by a daemon thread to handle deferred processing.

Reimplemented from ACE_Task_Base.

Definition at line 55 of file Stream_Modules.cpp.

References ACE_TRACE.

00056 {
00057   ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE>::svc");
00058   return -1;
00059 }


Member Data Documentation

template<ACE_SYNCH_DECL >
ACE_Stream_Head<>::ACE_ALLOC_HOOK_DECLARE
 

Declare the dynamic allocation hooks.

Reimplemented from ACE_Task< ACE_SYNCH_USE >.

Definition at line 75 of file Stream_Modules.h.


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 11:30:18 2006 for ACE by doxygen 1.3.6