Routing_Slip_Queue.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 // $Id: Routing_Slip_Queue.h 81419 2008-04-24 11:35:22Z johnnyw $
00004 
00005 #ifndef TAO_NOTIFY_ROUTING_SLIP_QUEUE_H
00006 #define TAO_NOTIFY_ROUTING_SLIP_QUEUE_H
00007 #include /**/ "ace/pre.h"
00008 
00009 #include "orbsvcs/Notify/Routing_Slip.h"
00010 
00011 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00012 # pragma once
00013 #endif /* ACE_LACKS_PRAGMA_ONCE */
00014 
00015 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00016 
00017 namespace TAO_Notify
00018 {
00019   /**
00020    * \brief A queue of Routing_Slips waiting to be persisted.
00021    *
00022    * The Routing_Slip_Queue keeps a queue of Routing_Slips waiting
00023    * to be written to persistent storage.  The "allowed" parameter
00024    * determines how many Routing_Slips can be handled simultaneously
00025    * by the persistent storage.  Until this threshold is reached,
00026    * Routing_Slips are not held in the queue, but pass straight through.
00027    *
00028    * Once the allowe number of Routing_Slips are being handled, any
00029    * additional requests are held in the queue until persistence is
00030    * complete for another Routing_Slips.
00031    *
00032    * Having Routing_Slips waiting in the queue is "a good thing" [TM]
00033    * because it allows delivery completions to be applied to the
00034    * routing slip before it is written -- thereby reducing or completely
00035    * eliminating the number of actual writes to persistent storage.
00036    *
00037    * Experimentation indicates that a good value for "allowed" is 1.
00038    *
00039    * Allowed == 0 is treated as a special case meaning pass all Routing_Slips
00040    * through the queue immediately.  Setting it a good way to test how well
00041    * your storage device withstands continuous beating.
00042    */
00043   class TAO_Notify_Serv_Export Routing_Slip_Queue
00044   {
00045     typedef ACE_Unbounded_Queue <Routing_Slip_Ptr> Queue;
00046     typedef ACE_Guard< TAO_SYNCH_MUTEX > Guard;
00047   public:
00048     /**
00049      * \brief Construct setting "allowed".
00050      * \param allowed the number of Routing_Slips that can be handled
00051      *  simultaneously by the persistent store.
00052      */
00053     Routing_Slip_Queue (size_t allowed = 1);
00054 
00055     /// Destructor.
00056     ~Routing_Slip_Queue ();
00057 
00058     /**
00059      * \brief Add a routing slip to the tail of the queue and dispatch if necessary.
00060      */
00061     void add (const Routing_Slip_Ptr & routing_slip);
00062     /**
00063      * \brief A call back to indicate that processing is complete for a previously-queued
00064      * Routing_Slip.
00065      */
00066     void complete ();
00067 
00068     /**
00069      * /brief Adjust the "allowed" value on-the-fly (not recommended, but it works.)
00070      */
00071     void set_allowed (size_t allowed);
00072 
00073   private:
00074     void dispatch (Guard & guard);
00075     bool dispatch_one (Guard & guard);
00076 
00077   private:
00078     Routing_Slip_Queue (const Routing_Slip_Queue & rhs);
00079     Routing_Slip_Queue & operator = (const Routing_Slip_Queue & rhs);
00080   private:
00081     // configuration setting
00082     size_t allowed_;
00083     /// Protection for internal information
00084     TAO_SYNCH_MUTEX internals_;
00085     size_t active_;
00086     Queue queue_;
00087 
00088   };
00089 } // namespace
00090 
00091 TAO_END_VERSIONED_NAMESPACE_DECL
00092 
00093 #include /**/ "ace/post.h"
00094 #endif /* TAO_NOTIFY_ROUTING_SLIP_QUEUE_H */

Generated on Tue Feb 2 17:45:29 2010 for TAO_CosNotification by  doxygen 1.4.7