TAO_Notify::Routing_Slip_Queue Class Reference

A queue of Routing_Slips waiting to be persisted. More...

#include <Routing_Slip_Queue.h>

Collaboration diagram for TAO_Notify::Routing_Slip_Queue:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Routing_Slip_Queue (size_t allowed=1)
 Construct setting "allowed".

 ~Routing_Slip_Queue ()
 Destructor.

void add (const Routing_Slip_Ptr &routing_slip)
 Add a routing slip to the tail of the queue and dispatch if necessary.

void complete ()
 A call back to indicate that processing is complete for a previously-queued Routing_Slip.

void set_allowed (size_t allowed)

Private Types

typedef ACE_Unbounded_Queue<
Routing_Slip_Ptr
Queue
typedef ACE_Guard< TAO_SYNCH_MUTEXGuard

Private Member Functions

void dispatch (Guard &guard)
bool dispatch_one (Guard &guard)
 Routing_Slip_Queue (const Routing_Slip_Queue &rhs)
Routing_Slip_Queueoperator= (const Routing_Slip_Queue &rhs)

Private Attributes

size_t allowed_
TAO_SYNCH_MUTEX internals_
 Protection for internal information.

size_t active_
Queue queue_

Detailed Description

A queue of Routing_Slips waiting to be persisted.

The Routing_Slip_Queue keeps a queue of Routing_Slips waiting to be written to persistent storage. The "allowed" parameter determines how many Routing_Slips can be handled simultaneously by the persistent storage. Until this threshold is reached, Routing_Slips are not held in the queue, but pass straight through.

Once the allowe number of Routing_Slips are being handled, any additional requests are held in the queue until persistence is complete for another Routing_Slips.

Having Routing_Slips waiting in the queue is "a good thing" [TM] because it allows delivery completions to be applied to the routing slip before it is written -- thereby reducing or completely eliminating the number of actual writes to persistent storage.

Experimentation indicates that a good value for "allowed" is 1.

Allowed == 0 is treated as a special case meaning pass all Routing_Slips through the queue immediately. Setting it a good way to test how well your storage device withstands continuous beating.

Definition at line 43 of file Routing_Slip_Queue.h.


Member Typedef Documentation

typedef ACE_Guard< TAO_SYNCH_MUTEX > TAO_Notify::Routing_Slip_Queue::Guard [private]
 

Definition at line 46 of file Routing_Slip_Queue.h.

Referenced by add(), complete(), dispatch(), dispatch_one(), and set_allowed().

typedef ACE_Unbounded_Queue<Routing_Slip_Ptr> TAO_Notify::Routing_Slip_Queue::Queue [private]
 

Definition at line 45 of file Routing_Slip_Queue.h.


Constructor & Destructor Documentation

TAO_Notify::Routing_Slip_Queue::Routing_Slip_Queue size_t  allowed = 1  ) 
 

Construct setting "allowed".

Parameters:
allowed the number of Routing_Slips that can be handled simultaneously by the persistent store.

Definition at line 18 of file Routing_Slip_Queue.cpp.

00019     : allowed_ (allowed)
00020     , active_ (0)
00021   {
00022   }

TAO_Notify::Routing_Slip_Queue::~Routing_Slip_Queue  ) 
 

Destructor.

Definition at line 24 of file Routing_Slip_Queue.cpp.

00025   {
00026   }

TAO_Notify::Routing_Slip_Queue::Routing_Slip_Queue const Routing_Slip_Queue rhs  )  [private]
 


Member Function Documentation

void TAO_Notify::Routing_Slip_Queue::add const Routing_Slip_Ptr routing_slip  ) 
 

Add a routing slip to the tail of the queue and dispatch if necessary.

Definition at line 29 of file Routing_Slip_Queue.cpp.

References ACE_ASSERT, allowed_, dispatch(), ACE_Unbounded_Queue< T >::enqueue_tail(), Guard, ACE_Guard< ACE_LOCK >::locked(), ACE_Guard< ACE_LOCK >::release(), and TAO_Notify::Routing_Slip_Ptr.

Referenced by TAO_Notify::Routing_Slip::add_to_persist_queue().

00030   {
00031     Guard guard (internals_);
00032     ACE_ASSERT (guard.locked()); // check recursion
00033     if (this->allowed_ == 0)
00034     {
00035       ++this->active_;
00036       guard.release ();
00037       routing_slip->at_front_of_persist_queue ();
00038 //      guard.acquire ();
00039     }
00040     else
00041     {
00042       this->queue_.enqueue_tail (routing_slip);
00043       dispatch (guard);
00044     }
00045   }

void TAO_Notify::Routing_Slip_Queue::complete  ) 
 

A call back to indicate that processing is complete for a previously-queued Routing_Slip.

Definition at line 47 of file Routing_Slip_Queue.cpp.

References ACE_ASSERT, dispatch(), Guard, and ACE_Guard< ACE_LOCK >::locked().

Referenced by TAO_Notify::Routing_Slip::at_front_of_persist_queue(), TAO_Notify::Routing_Slip::enter_state_saving(), and TAO_Notify::Routing_Slip::persist_complete().

00048   {
00049     Guard guard (internals_);
00050     ACE_ASSERT (guard.locked()); // check recursion
00051     ACE_ASSERT (this->active_ > 0);
00052     --this->active_;
00053     dispatch (guard);
00054   }

void TAO_Notify::Routing_Slip_Queue::dispatch Guard guard  )  [private]
 

Definition at line 57 of file Routing_Slip_Queue.cpp.

References allowed_, dispatch_one(), and Guard.

Referenced by add(), complete(), and set_allowed().

00058   {
00059     // we start out pretty nice,
00060     // but the more work we do for other people
00061     // the less nice we get.
00062     size_t nice = this->allowed_ + 1;
00063     while (nice > 0 && (this->active_ < this->allowed_))
00064     {
00065       if (dispatch_one (guard))
00066       {
00067         --nice;
00068       }
00069       else
00070       {
00071         // that's about as nice as I get.
00072         nice = 0;
00073       }
00074     }
00075   }

bool TAO_Notify::Routing_Slip_Queue::dispatch_one Guard guard  )  [private]
 

Definition at line 78 of file Routing_Slip_Queue.cpp.

References ACE_Guard< ACE_LOCK >::acquire(), ACE_Unbounded_Queue< T >::dequeue_head(), Guard, ACE_Guard< ACE_LOCK >::release(), and TAO_Notify::Routing_Slip_Ptr.

Referenced by dispatch(), and set_allowed().

00079   {
00080     bool ok = false;
00081     Routing_Slip_Ptr routing_slip;
00082     if (this->queue_.dequeue_head (routing_slip) == 0)
00083     {
00084       ++this->active_;
00085       guard.release ();
00086       routing_slip->at_front_of_persist_queue ();
00087       guard.acquire ();
00088     }
00089     return ok;
00090   }

Routing_Slip_Queue& TAO_Notify::Routing_Slip_Queue::operator= const Routing_Slip_Queue rhs  )  [private]
 

void TAO_Notify::Routing_Slip_Queue::set_allowed size_t  allowed  ) 
 

/brief Adjust the "allowed" value on-the-fly (not recommended, but it works.)

Definition at line 93 of file Routing_Slip_Queue.cpp.

References allowed_, dispatch(), dispatch_one(), and Guard.

00094   {
00095     Guard guard (internals_);
00096     size_t allowed_was = this->allowed_;
00097     this->allowed_ = allowed;
00098     if (allowed == 0 && allowed_was != 0)
00099     {
00100       while (dispatch_one (guard))
00101       {
00102         ; // work happens in dispatc_one
00103       }
00104     }
00105     else
00106     {
00107       dispatch (guard);
00108     }
00109   }


Member Data Documentation

size_t TAO_Notify::Routing_Slip_Queue::active_ [private]
 

Definition at line 84 of file Routing_Slip_Queue.h.

size_t TAO_Notify::Routing_Slip_Queue::allowed_ [private]
 

Definition at line 81 of file Routing_Slip_Queue.h.

Referenced by add(), dispatch(), and set_allowed().

TAO_SYNCH_MUTEX TAO_Notify::Routing_Slip_Queue::internals_ [private]
 

Protection for internal information.

Definition at line 83 of file Routing_Slip_Queue.h.

Queue TAO_Notify::Routing_Slip_Queue::queue_ [private]
 

Definition at line 85 of file Routing_Slip_Queue.h.


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 13:34:30 2006 for TAO_CosNotification by doxygen 1.3.6