Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

ACE_Dynamic_Message_Strategy Class Reference

An abstract base class which provides dynamic priority evaluation methods for use by the <ACE_Dynamic_Message_Queue> class or any other class which needs to manage the priorities of a collection of <ACE_Message_Block>s dynamically. More...

#include <Message_Block.h>

Inheritance diagram for ACE_Dynamic_Message_Strategy:

Inheritance graph
[legend]
Collaboration diagram for ACE_Dynamic_Message_Strategy:

Collaboration graph
[legend]
List of all members.

Public Types

enum  Priority_Status { PENDING = 0x01, LATE = 0x02, BEYOND_LATE = 0x04, ANY_STATUS = 0x07 }

Public Methods

 ACE_Dynamic_Message_Strategy (u_long static_bit_field_mask, u_long static_bit_field_shift, u_long dynamic_priority_max, u_long dynamic_priority_offset)
 Constructor. More...

virtual ~ACE_Dynamic_Message_Strategy (void)
 Virtual destructor. More...

Priority_Status priority_status (ACE_Message_Block &mb, const ACE_Time_Value &tv)
 Updates the message's priority and returns its priority status. More...

u_long static_bit_field_mask (void) const
 Get static bit field mask. More...

void static_bit_field_mask (u_long)
 Set static bit field mask. More...

u_long static_bit_field_shift (void) const
 Get left shift value to make room for static bit field. More...

void static_bit_field_shift (u_long)
 Set left shift value to make room for static bit field. More...

u_long dynamic_priority_max (void) const
 Get maximum supported priority value. More...

void dynamic_priority_max (u_long)
 Set maximum supported priority value. More...

u_long dynamic_priority_offset (void) const
 Get offset to boundary between signed range and unsigned range. More...

void dynamic_priority_offset (u_long)
 Set offset to boundary between signed range and unsigned range. More...

virtual void dump (void) const
 Dump the state of the strategy. More...


Protected Methods

virtual void convert_priority (ACE_Time_Value &priority, const ACE_Message_Block &mb)=0
 Hook method for dynamic priority conversion. More...


Protected Attributes

u_long static_bit_field_mask_
 This is a bit mask with all ones in the static bit field. More...

u_long static_bit_field_shift_
u_long dynamic_priority_max_
 Maximum supported priority value. More...

u_long dynamic_priority_offset_
 Offset to boundary between signed range and unsigned range. More...

ACE_Time_Value max_late_
 Maximum late time value that can be represented. More...

ACE_Time_Value min_pending_
 Minimum pending time value that can be represented. More...

ACE_Time_Value pending_shift_
 Time value by which to shift pending priority. More...


Detailed Description

An abstract base class which provides dynamic priority evaluation methods for use by the <ACE_Dynamic_Message_Queue> class or any other class which needs to manage the priorities of a collection of <ACE_Message_Block>s dynamically.

Methods for deadline and laxity based priority evaluation are provided. These methods assume a specific partitioning of the message priority number into a higher order dynamic bit field and a lower order static priority bit field. The default partitioning assumes an unsigned dynamic message priority field of 22 bits and an unsigned static message priority field of 10 bits. This corresponds to the initial values of the static class members. To provide a different partitioning, assign a different set of values to the static class memebers before using the static member functions.

Definition at line 867 of file Message_Block.h.


Member Enumeration Documentation

enum ACE_Dynamic_Message_Strategy::Priority_Status
 

Enumeration values:
PENDING  Message can still make its deadline.
LATE  Message cannot make its deadline.
BEYOND_LATE  Message is so late its priority is undefined.
ANY_STATUS  Mask to match any priority status.

Definition at line 876 of file Message_Block.h.

Referenced by priority_status, ACE_Dynamic_Message_Queue::refresh_late_queue, ACE_Dynamic_Message_Queue::refresh_pending_queue, and ACE_Dynamic_Message_Queue::sublist_enqueue_i.

00877   {
00878     /// Message can still make its deadline
00879     PENDING     = 0x01,
00880     /// Message cannot make its deadline
00881     LATE        = 0x02,
00882     /// Message is so late its priority is undefined
00883     BEYOND_LATE = 0x04,
00884     /// Mask to match any priority status
00885     ANY_STATUS  = 0x07
00886   };


Constructor & Destructor Documentation

ACE_Dynamic_Message_Strategy::ACE_Dynamic_Message_Strategy u_long    static_bit_field_mask,
u_long    static_bit_field_shift,
u_long    dynamic_priority_max,
u_long    dynamic_priority_offset
 

Constructor.

Definition at line 1194 of file Message_Block.cpp.

ACE_Dynamic_Message_Strategy::~ACE_Dynamic_Message_Strategy void    [virtual]
 

Virtual destructor.

Definition at line 1210 of file Message_Block.cpp.

01211 {
01212 }


Member Function Documentation

virtual void ACE_Dynamic_Message_Strategy::convert_priority ACE_Time_Value   priority,
const ACE_Message_Block   mb
[protected, pure virtual]
 

Hook method for dynamic priority conversion.

Implemented in ACE_Deadline_Message_Strategy.

Referenced by priority_status.

void ACE_Dynamic_Message_Strategy::dump void    const [virtual]
 

Dump the state of the strategy.

Reimplemented in ACE_Deadline_Message_Strategy.

Definition at line 1217 of file Message_Block.cpp.

References ACE_BEGIN_DUMP, ACE_DEBUG, ACE_END_DUMP, ACE_LIB_TEXT, ACE_TRACE, LM_DEBUG, max_late_, min_pending_, pending_shift_, ACE_Time_Value::sec, and ACE_Time_Value::usec.

Referenced by ACE_Dynamic_Message_Queue::dump, ACE_Laxity_Message_Strategy::dump, and ACE_Deadline_Message_Strategy::dump.

01218 {
01219   ACE_TRACE ("ACE_Dynamic_Message_Strategy::dump");
01220 
01221   ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
01222 
01223   ACE_DEBUG ((LM_DEBUG,
01224               ACE_LIB_TEXT ("static_bit_field_mask_ = %u\n")
01225               ACE_LIB_TEXT ("static_bit_field_shift_ = %u\n")
01226               ACE_LIB_TEXT ("dynamic_priority_max_ = %u\n")
01227               ACE_LIB_TEXT ("dynamic_priority_offset_ = %u\n")
01228               ACE_LIB_TEXT ("max_late_ = [%d sec, %d usec]\n")
01229               ACE_LIB_TEXT ("min_pending_ = [%d sec, %d usec]\n")
01230               ACE_LIB_TEXT ("pending_shift_ = [%d sec, %d usec]\n"),
01231               this->static_bit_field_mask_,
01232               this->static_bit_field_shift_,
01233               this->dynamic_priority_max_,
01234               this->dynamic_priority_offset_,
01235               this->max_late_.sec (),
01236               this->max_late_.usec (),
01237               this->min_pending_.sec (),
01238               this->min_pending_.usec (),
01239               this->pending_shift_.sec (),
01240               this->pending_shift_.usec ()));
01241 
01242   ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
01243 }

ACE_INLINE void ACE_Dynamic_Message_Strategy::dynamic_priority_max u_long   
 

Set maximum supported priority value.

Definition at line 551 of file Message_Block.i.

References dynamic_priority_max_, and pending_shift_.

00552 {
00553   // pending_shift_ depends on dynamic_priority_max_: for performance
00554   // reasons, the value in pending_shift_ is (re)calculated only when
00555   // dynamic_priority_max_ is initialized or changes, and is stored
00556   // as a class member rather than being a derived value.
00557   dynamic_priority_max_ = ul;
00558   pending_shift_ = ACE_Time_Value (0, ul);
00559 }

ACE_INLINE u_long ACE_Dynamic_Message_Strategy::dynamic_priority_max void    const
 

Get maximum supported priority value.

Definition at line 544 of file Message_Block.i.

References dynamic_priority_max_.

00545 {
00546   return dynamic_priority_max_;
00547 }

ACE_INLINE void ACE_Dynamic_Message_Strategy::dynamic_priority_offset u_long   
 

Set offset to boundary between signed range and unsigned range.

Definition at line 570 of file Message_Block.i.

References dynamic_priority_offset_, max_late_, and min_pending_.

00571 {
00572   // max_late_ and min_pending_ depend on dynamic_priority_offset_:
00573   // for performance reasons, the values in max_late_ and min_pending_
00574   // are (re)calculated only when dynamic_priority_offset_ is
00575   // initialized or changes, and are stored as a class member rather
00576   // than being derived each time one of their values is needed.
00577   dynamic_priority_offset_ = ul;
00578   max_late_ = ACE_Time_Value (0, ul - 1);
00579   min_pending_ = ACE_Time_Value (0, ul);
00580 }

ACE_INLINE u_long ACE_Dynamic_Message_Strategy::dynamic_priority_offset void    const
 

Get offset to boundary between signed range and unsigned range.

Definition at line 563 of file Message_Block.i.

References dynamic_priority_offset_.

00564 {
00565   return dynamic_priority_offset_;
00566 }

ACE_INLINE ACE_Dynamic_Message_Strategy::Priority_Status ACE_Dynamic_Message_Strategy::priority_status ACE_Message_Block   mb,
const ACE_Time_Value   tv
 

Updates the message's priority and returns its priority status.

Definition at line 585 of file Message_Block.i.

References ACE_ONE_SECOND_IN_USECS, BEYOND_LATE, convert_priority, LATE, max_late_, min_pending_, ACE_Message_Block::msg_priority, PENDING, pending_shift_, Priority_Status, ACE_Time_Value::sec, static_bit_field_mask_, static_bit_field_shift_, ACE_Time_Value::usec, and ACE_Time_Value::zero.

Referenced by ACE_Dynamic_Message_Queue::enqueue_i, ACE_Dynamic_Message_Queue::refresh_late_queue, ACE_Dynamic_Message_Queue::refresh_pending_queue, and ACE_Dynamic_Message_Queue::sublist_enqueue_i.

00587 {
00588   // default the message to have pending priority status
00589   Priority_Status status = ACE_Dynamic_Message_Strategy::PENDING;
00590 
00591   // start with the passed absolute time as the message's priority, then
00592   // call the polymorphic hook method to (at least partially) convert
00593   // the absolute time and message attributes into the message's priority
00594   ACE_Time_Value priority (tv);
00595   convert_priority (priority, mb);
00596 
00597   // if the priority is negative, the message is pending
00598   if (priority < ACE_Time_Value::zero)
00599     {
00600       // priority for pending messages must be shifted
00601       // upward above the late priority range
00602       priority += pending_shift_;
00603       if (priority < min_pending_)
00604         priority = min_pending_;
00605     }
00606   // otherwise, if the priority is greater than the maximum late
00607   // priority value that can be represented, it is beyond late
00608   else if (priority > max_late_)
00609     {
00610       // all messages that are beyond late are assigned lowest priority (zero)
00611       mb.msg_priority (0);
00612       return ACE_Dynamic_Message_Strategy::BEYOND_LATE;
00613     }
00614   // otherwise, the message is late, but its priority is correct
00615   else
00616     status = ACE_Dynamic_Message_Strategy::LATE;
00617 
00618   // use (fast) bitwise operators to isolate and replace
00619   // the dynamic portion of the message's priority
00620   mb.msg_priority((mb.msg_priority() & static_bit_field_mask_) |
00621                   ((priority.usec () + ACE_ONE_SECOND_IN_USECS * priority.sec ()) <<
00622                    static_bit_field_shift_));
00623 
00624   return status;
00625 }

ACE_INLINE void ACE_Dynamic_Message_Strategy::static_bit_field_mask u_long   
 

Set static bit field mask.

Definition at line 523 of file Message_Block.i.

References static_bit_field_mask_.

00524 {
00525   static_bit_field_mask_ = ul;
00526 }

ACE_INLINE u_long ACE_Dynamic_Message_Strategy::static_bit_field_mask void    const
 

Get static bit field mask.

Definition at line 516 of file Message_Block.i.

References static_bit_field_mask_.

00517 {
00518   return static_bit_field_mask_;
00519 }

ACE_INLINE void ACE_Dynamic_Message_Strategy::static_bit_field_shift u_long   
 

Set left shift value to make room for static bit field.

Definition at line 537 of file Message_Block.i.

References static_bit_field_shift_.

00538 {
00539   static_bit_field_shift_ = ul;
00540 }

ACE_INLINE u_long ACE_Dynamic_Message_Strategy::static_bit_field_shift void    const
 

Get left shift value to make room for static bit field.

Definition at line 530 of file Message_Block.i.

References static_bit_field_shift_.

00531 {
00532   return static_bit_field_shift_;
00533 }


Member Data Documentation

u_long ACE_Dynamic_Message_Strategy::dynamic_priority_max_ [protected]
 

Maximum supported priority value.

Definition at line 944 of file Message_Block.h.

Referenced by dynamic_priority_max.

u_long ACE_Dynamic_Message_Strategy::dynamic_priority_offset_ [protected]
 

Offset to boundary between signed range and unsigned range.

Definition at line 947 of file Message_Block.h.

Referenced by dynamic_priority_offset.

ACE_Time_Value ACE_Dynamic_Message_Strategy::max_late_ [protected]
 

Maximum late time value that can be represented.

Definition at line 950 of file Message_Block.h.

Referenced by dump, dynamic_priority_offset, and priority_status.

ACE_Time_Value ACE_Dynamic_Message_Strategy::min_pending_ [protected]
 

Minimum pending time value that can be represented.

Definition at line 953 of file Message_Block.h.

Referenced by dump, dynamic_priority_offset, and priority_status.

ACE_Time_Value ACE_Dynamic_Message_Strategy::pending_shift_ [protected]
 

Time value by which to shift pending priority.

Definition at line 956 of file Message_Block.h.

Referenced by dump, dynamic_priority_max, and priority_status.

u_long ACE_Dynamic_Message_Strategy::static_bit_field_mask_ [protected]
 

This is a bit mask with all ones in the static bit field.

Definition at line 934 of file Message_Block.h.

Referenced by priority_status, and static_bit_field_mask.

u_long ACE_Dynamic_Message_Strategy::static_bit_field_shift_ [protected]
 

This is a left shift value to make room for static bit field: this value should be the logarithm base 2 of (static_bit_field_mask_ + 1).

Definition at line 941 of file Message_Block.h.

Referenced by priority_status, and static_bit_field_shift.


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 12:47:36 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002