Public Member Functions | Public Attributes | Private Member Functions

ACE_Stream_Head< ACE_SYNCH_DECL > 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< ACE_SYNCH_DECL >:
Inheritance graph
[legend]
Collaboration diagram for ACE_Stream_Head< ACE_SYNCH_DECL >:
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< ACE_SYNCH_DECL >

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_Stream_Head< ACE_SYNCH_DECL >::ACE_Stream_Head ( void   ) 

Construction.

Definition at line 19 of file Stream_Modules.cpp.

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

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

Destruction.

Definition at line 25 of file Stream_Modules.cpp.

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


Member Function Documentation

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

Definition at line 84 of file Stream_Modules.cpp.

{
  ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE>::canonical_flush");
  char *cp = mb->rd_ptr ();

  if (ACE_BIT_ENABLED (*cp, ACE_Task_Flags::ACE_FLUSHR))
    {
      this->flush (ACE_Task_Flags::ACE_FLUSHALL);
      ACE_CLR_BITS (*cp, ACE_Task_Flags::ACE_FLUSHR);
    }

  if (ACE_BIT_ENABLED (*cp, ACE_Task_Flags::ACE_FLUSHW))
    return this->reply (mb);
  else
    mb->release ();
  return 0;
}

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

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

Reimplemented from ACE_Task_Base.

Definition at line 48 of file Stream_Modules.cpp.

{
  ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE>::close");
  return 0;
}

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

Performs canonical flushing at the ACE_Stream Head.

Definition at line 62 of file Stream_Modules.cpp.

{
  ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE>::control");
  ACE_IO_Cntl_Msg *ioc = (ACE_IO_Cntl_Msg *) mb->rd_ptr ();
  ACE_IO_Cntl_Msg::ACE_IO_Cntl_Cmds cmd;

  switch (cmd = ioc->cmd ())
    {
    case ACE_IO_Cntl_Msg::SET_LWM:
    case ACE_IO_Cntl_Msg::SET_HWM:
      this->water_marks (cmd, *(size_t *) mb->cont ()->rd_ptr ());
      ioc->rval (0);
      break;
    default:
      return 0;
    }
  return ioc->rval ();
}

template<ACE_SYNCH_DECL >
void ACE_Stream_Head< ACE_SYNCH_DECL >::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.

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

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

Terminates object when dynamic unlinking occurs.

Reimplemented from ACE_Shared_Object.

Definition at line 150 of file Stream_Modules.cpp.

{
  ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE>::fini");
  return 0;
}

template<ACE_SYNCH_DECL >
int ACE_Stream_Head< ACE_SYNCH_DECL >::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.

{
  ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE>::info");
  const ACE_TCHAR *name = this->name ();

  if (*strp == 0 && (*strp = ACE_OS::strdup (name)) == 0)
    return -1;
  else
    ACE_OS::strsncpy (*strp, name, length);
  return static_cast<int> (ACE_OS::strlen (name));
}

template<ACE_SYNCH_DECL >
int ACE_Stream_Head< ACE_SYNCH_DECL >::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.

{
  ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE>::init");
  return 0;
}

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

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

Reimplemented from ACE_Task_Base.

Definition at line 41 of file Stream_Modules.cpp.

{
  ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE>::open");
  return 0;
}

template<ACE_SYNCH_DECL >
int ACE_Stream_Head< ACE_SYNCH_DECL >::put ( ACE_Message_Block ,
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 svc() hook method.

Reimplemented from ACE_Task_Base.

Definition at line 103 of file Stream_Modules.cpp.

{
  ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE>::put");
  int res = 0;

  if (mb->msg_type () == ACE_Message_Block::MB_IOCTL
      && (res = this->control (mb)) == -1)
    return res;

  if (this->is_writer ())
    return this->put_next (mb, tv);
  else // this->is_reader ()
    {
      switch (mb->msg_type ())
        {
        case ACE_Message_Block::MB_FLUSH:
          return this->canonical_flush (mb);
        default:
          break;
        }

      return this->putq (mb, tv);
    }
}

template<ACE_SYNCH_DECL >
int ACE_Stream_Head< ACE_SYNCH_DECL >::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.

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


Member Data Documentation

template<ACE_SYNCH_DECL >
ACE_Stream_Head< ACE_SYNCH_DECL >::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:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines