#include <Message_Block.h>
Inheritance diagram for ACE_Dynamic_Message_Strategy:
Public Types | |
enum | Priority_Status { PENDING = 0x01, LATE = 0x02, BEYOND_LATE = 0x04, ANY_STATUS = 0x07 } |
Public Member Functions | |
ACE_Dynamic_Message_Strategy (unsigned long static_bit_field_mask, unsigned long static_bit_field_shift, unsigned long dynamic_priority_max, unsigned long dynamic_priority_offset) | |
Constructor. | |
virtual | ~ACE_Dynamic_Message_Strategy (void) |
Virtual destructor. | |
Priority_Status | priority_status (ACE_Message_Block &mb, const ACE_Time_Value &tv) |
Updates the message's priority and returns its priority status. | |
unsigned long | static_bit_field_mask (void) const |
Get static bit field mask. | |
void | static_bit_field_mask (unsigned long) |
Set static bit field mask. | |
unsigned long | static_bit_field_shift (void) const |
Get left shift value to make room for static bit field. | |
void | static_bit_field_shift (unsigned long) |
Set left shift value to make room for static bit field. | |
unsigned long | dynamic_priority_max (void) const |
Get maximum supported priority value. | |
void | dynamic_priority_max (unsigned long) |
Set maximum supported priority value. | |
unsigned long | dynamic_priority_offset (void) const |
Get offset to boundary between signed range and unsigned range. | |
void | dynamic_priority_offset (unsigned long) |
Set offset to boundary between signed range and unsigned range. | |
virtual void | dump (void) const |
Dump the state of the strategy. | |
Protected Member Functions | |
virtual void | convert_priority (ACE_Time_Value &priority, const ACE_Message_Block &mb)=0 |
Hook method for dynamic priority conversion. | |
Protected Attributes | |
unsigned long | static_bit_field_mask_ |
This is a bit mask with all ones in the static bit field. | |
unsigned long | static_bit_field_shift_ |
unsigned long | dynamic_priority_max_ |
Maximum supported priority value. | |
unsigned long | dynamic_priority_offset_ |
Offset to boundary between signed range and unsigned range. | |
ACE_Time_Value | max_late_ |
Maximum late time value that can be represented. | |
ACE_Time_Value | min_pending_ |
Minimum pending time value that can be represented. | |
ACE_Time_Value | pending_shift_ |
Time value by which to shift pending priority. |
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 877 of file Message_Block.h.
|
Definition at line 886 of file Message_Block.h. Referenced by priority_status().
00887 { 00888 /// Message can still make its deadline 00889 PENDING = 0x01, 00890 /// Message cannot make its deadline 00891 LATE = 0x02, 00892 /// Message is so late its priority is undefined 00893 BEYOND_LATE = 0x04, 00894 /// Mask to match any priority status 00895 ANY_STATUS = 0x07 00896 }; |
|
Constructor.
Definition at line 1232 of file Message_Block.cpp.
01236 : static_bit_field_mask_ (static_bit_field_mask), 01237 static_bit_field_shift_ (static_bit_field_shift), 01238 dynamic_priority_max_ (dynamic_priority_max), 01239 dynamic_priority_offset_ (dynamic_priority_offset), 01240 max_late_ (0, dynamic_priority_offset - 1), 01241 min_pending_ (0, dynamic_priority_offset), 01242 pending_shift_ (0, dynamic_priority_max) 01243 { 01244 } |
|
Virtual destructor.
Definition at line 1248 of file Message_Block.cpp.
01249 { 01250 } |
|
Hook method for dynamic priority conversion.
Implemented in ACE_Deadline_Message_Strategy, and ACE_Laxity_Message_Strategy. Referenced by priority_status(). |
|
Dump the state of the strategy.
Reimplemented in ACE_Deadline_Message_Strategy, and ACE_Laxity_Message_Strategy. Definition at line 1255 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().
01256 { 01257 #if defined (ACE_HAS_DUMP) 01258 ACE_TRACE ("ACE_Dynamic_Message_Strategy::dump"); 01259 01260 ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); 01261 01262 ACE_DEBUG ((LM_DEBUG, 01263 ACE_LIB_TEXT ("static_bit_field_mask_ = %u\n") 01264 ACE_LIB_TEXT ("static_bit_field_shift_ = %u\n") 01265 ACE_LIB_TEXT ("dynamic_priority_max_ = %u\n") 01266 ACE_LIB_TEXT ("dynamic_priority_offset_ = %u\n") 01267 ACE_LIB_TEXT ("max_late_ = [%d sec, %d usec]\n") 01268 ACE_LIB_TEXT ("min_pending_ = [%d sec, %d usec]\n") 01269 ACE_LIB_TEXT ("pending_shift_ = [%d sec, %d usec]\n"), 01270 this->static_bit_field_mask_, 01271 this->static_bit_field_shift_, 01272 this->dynamic_priority_max_, 01273 this->dynamic_priority_offset_, 01274 this->max_late_.sec (), 01275 this->max_late_.usec (), 01276 this->min_pending_.sec (), 01277 this->min_pending_.usec (), 01278 this->pending_shift_.sec (), 01279 this->pending_shift_.usec ())); 01280 01281 ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); 01282 #endif /* ACE_HAS_DUMP */ 01283 } |
|
Set maximum supported priority value.
Definition at line 549 of file Message_Block.inl. References ACE_Time_Value, dynamic_priority_max_, and pending_shift_.
00550 { 00551 // pending_shift_ depends on dynamic_priority_max_: for performance 00552 // reasons, the value in pending_shift_ is (re)calculated only when 00553 // dynamic_priority_max_ is initialized or changes, and is stored 00554 // as a class member rather than being a derived value. 00555 dynamic_priority_max_ = ul; 00556 pending_shift_ = ACE_Time_Value (0, ul); 00557 } |
|
Get maximum supported priority value.
Definition at line 542 of file Message_Block.inl. References dynamic_priority_max_.
00543 { 00544 return dynamic_priority_max_; 00545 } |
|
Set offset to boundary between signed range and unsigned range.
Definition at line 568 of file Message_Block.inl. References ACE_Time_Value, dynamic_priority_offset_, max_late_, and min_pending_.
00569 { 00570 // max_late_ and min_pending_ depend on dynamic_priority_offset_: 00571 // for performance reasons, the values in max_late_ and min_pending_ 00572 // are (re)calculated only when dynamic_priority_offset_ is 00573 // initialized or changes, and are stored as a class member rather 00574 // than being derived each time one of their values is needed. 00575 dynamic_priority_offset_ = ul; 00576 max_late_ = ACE_Time_Value (0, ul - 1); 00577 min_pending_ = ACE_Time_Value (0, ul); 00578 } |
|
Get offset to boundary between signed range and unsigned range.
Definition at line 561 of file Message_Block.inl. References dynamic_priority_offset_.
00562 { 00563 return dynamic_priority_offset_; 00564 } |
|
Updates the message's priority and returns its priority status.
Definition at line 583 of file Message_Block.inl. 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_, and ACE_Time_Value::usec(). 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().
00585 { 00586 // default the message to have pending priority status 00587 Priority_Status status = ACE_Dynamic_Message_Strategy::PENDING; 00588 00589 // start with the passed absolute time as the message's priority, then 00590 // call the polymorphic hook method to (at least partially) convert 00591 // the absolute time and message attributes into the message's priority 00592 ACE_Time_Value priority (tv); 00593 convert_priority (priority, mb); 00594 00595 // if the priority is negative, the message is pending 00596 if (priority < ACE_Time_Value::zero) 00597 { 00598 // priority for pending messages must be shifted 00599 // upward above the late priority range 00600 priority += pending_shift_; 00601 if (priority < min_pending_) 00602 priority = min_pending_; 00603 } 00604 // otherwise, if the priority is greater than the maximum late 00605 // priority value that can be represented, it is beyond late 00606 else if (priority > max_late_) 00607 { 00608 // all messages that are beyond late are assigned lowest priority (zero) 00609 mb.msg_priority (0); 00610 return ACE_Dynamic_Message_Strategy::BEYOND_LATE; 00611 } 00612 // otherwise, the message is late, but its priority is correct 00613 else 00614 status = ACE_Dynamic_Message_Strategy::LATE; 00615 00616 // use (fast) bitwise operators to isolate and replace 00617 // the dynamic portion of the message's priority 00618 mb.msg_priority((mb.msg_priority() & static_bit_field_mask_) | 00619 ((priority.usec () + ACE_ONE_SECOND_IN_USECS * priority.sec ()) << 00620 static_bit_field_shift_)); 00621 00622 return status; 00623 } |
|
Set static bit field mask.
Definition at line 521 of file Message_Block.inl. References static_bit_field_mask_.
00522 { 00523 static_bit_field_mask_ = ul; 00524 } |
|
Get static bit field mask.
Definition at line 514 of file Message_Block.inl. References static_bit_field_mask_.
00515 { 00516 return static_bit_field_mask_; 00517 } |
|
Set left shift value to make room for static bit field.
Definition at line 535 of file Message_Block.inl. References static_bit_field_shift_.
00536 { 00537 static_bit_field_shift_ = ul; 00538 } |
|
Get left shift value to make room for static bit field.
Definition at line 528 of file Message_Block.inl. References static_bit_field_shift_.
00529 { 00530 return static_bit_field_shift_; 00531 } |
|
Maximum supported priority value.
Definition at line 954 of file Message_Block.h. Referenced by dynamic_priority_max(). |
|
Offset to boundary between signed range and unsigned range.
Definition at line 957 of file Message_Block.h. Referenced by dynamic_priority_offset(). |
|
Maximum late time value that can be represented.
Definition at line 960 of file Message_Block.h. Referenced by dump(), dynamic_priority_offset(), and priority_status(). |
|
Minimum pending time value that can be represented.
Definition at line 963 of file Message_Block.h. Referenced by dump(), dynamic_priority_offset(), and priority_status(). |
|
Time value by which to shift pending priority.
Definition at line 966 of file Message_Block.h. Referenced by dump(), dynamic_priority_max(), and priority_status(). |
|
This is a bit mask with all ones in the static bit field.
Definition at line 944 of file Message_Block.h. Referenced by priority_status(), and static_bit_field_mask(). |
|
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 951 of file Message_Block.h. Referenced by priority_status(), and static_bit_field_shift(). |