#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 880 of file Message_Block.h.
|
Definition at line 889 of file Message_Block.h. Referenced by priority_status().
00890 { 00891 /// Message can still make its deadline 00892 PENDING = 0x01, 00893 /// Message cannot make its deadline 00894 LATE = 0x02, 00895 /// Message is so late its priority is undefined 00896 BEYOND_LATE = 0x04, 00897 /// Mask to match any priority status 00898 ANY_STATUS = 0x07 00899 }; |
|
Constructor.
Definition at line 1276 of file Message_Block.cpp.
01280 : static_bit_field_mask_ (static_bit_field_mask), 01281 static_bit_field_shift_ (static_bit_field_shift), 01282 dynamic_priority_max_ (dynamic_priority_max), 01283 dynamic_priority_offset_ (dynamic_priority_offset), 01284 max_late_ (0, dynamic_priority_offset - 1), 01285 min_pending_ (0, dynamic_priority_offset), 01286 pending_shift_ (0, dynamic_priority_max) 01287 { 01288 } |
|
Virtual destructor.
Definition at line 1292 of file Message_Block.cpp.
01293 { 01294 } |
|
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 1345 of file Message_Block.cpp. References ACE_BEGIN_DUMP, ACE_DEBUG, ACE_END_DUMP, ACE_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().
01346 { 01347 #if defined (ACE_HAS_DUMP) 01348 ACE_TRACE ("ACE_Dynamic_Message_Strategy::dump"); 01349 01350 ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); 01351 01352 ACE_DEBUG ((LM_DEBUG, 01353 ACE_TEXT ("static_bit_field_mask_ = %u\n") 01354 ACE_TEXT ("static_bit_field_shift_ = %u\n") 01355 ACE_TEXT ("dynamic_priority_max_ = %u\n") 01356 ACE_TEXT ("dynamic_priority_offset_ = %u\n") 01357 ACE_TEXT ("max_late_ = [%d sec, %d usec]\n") 01358 ACE_TEXT ("min_pending_ = [%d sec, %d usec]\n") 01359 ACE_TEXT ("pending_shift_ = [%d sec, %d usec]\n"), 01360 this->static_bit_field_mask_, 01361 this->static_bit_field_shift_, 01362 this->dynamic_priority_max_, 01363 this->dynamic_priority_offset_, 01364 this->max_late_.sec (), 01365 this->max_late_.usec (), 01366 this->min_pending_.sec (), 01367 this->min_pending_.usec (), 01368 this->pending_shift_.sec (), 01369 this->pending_shift_.usec ())); 01370 01371 ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); 01372 #endif /* ACE_HAS_DUMP */ 01373 } |
|
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 1297 of file Message_Block.cpp. 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().
01299 { 01300 // default the message to have pending priority status 01301 Priority_Status status = ACE_Dynamic_Message_Strategy::PENDING; 01302 01303 // start with the passed absolute time as the message's priority, then 01304 // call the polymorphic hook method to (at least partially) convert 01305 // the absolute time and message attributes into the message's priority 01306 ACE_Time_Value priority (tv); 01307 convert_priority (priority, mb); 01308 01309 // if the priority is negative, the message is pending 01310 if (priority < ACE_Time_Value::zero) 01311 { 01312 // priority for pending messages must be shifted 01313 // upward above the late priority range 01314 priority += pending_shift_; 01315 if (priority < min_pending_) 01316 priority = min_pending_; 01317 } 01318 // otherwise, if the priority is greater than the maximum late 01319 // priority value that can be represented, it is beyond late 01320 else if (priority > max_late_) 01321 { 01322 // all messages that are beyond late are assigned lowest priority (zero) 01323 mb.msg_priority (0); 01324 return ACE_Dynamic_Message_Strategy::BEYOND_LATE; 01325 } 01326 // otherwise, the message is late, but its priority is correct 01327 else 01328 status = ACE_Dynamic_Message_Strategy::LATE; 01329 01330 // use (fast) bitwise operators to isolate and replace 01331 // the dynamic portion of the message's priority 01332 mb.msg_priority((mb.msg_priority() & static_bit_field_mask_) | 01333 ((priority.usec () + 01334 ACE_ONE_SECOND_IN_USECS * (suseconds_t)(priority.sec())) << 01335 static_bit_field_shift_)); 01336 01337 // returns the priority status of the message 01338 return status; 01339 } |
|
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 957 of file Message_Block.h. Referenced by dynamic_priority_max(). |
|
Offset to boundary between signed range and unsigned range.
Definition at line 960 of file Message_Block.h. Referenced by dynamic_priority_offset(). |
|
Maximum late time value that can be represented.
Definition at line 963 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 966 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 969 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 947 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 954 of file Message_Block.h. Referenced by priority_status(), and static_bit_field_shift(). |