Message_Block.cpp

Go to the documentation of this file.
00001 #include "ace/Message_Block.h"
00002 
00003 #if !defined (__ACE_INLINE__)
00004 #include "ace/Message_Block.inl"
00005 #endif /* __ACE_INLINE__ */
00006 
00007 #include "ace/Guard_T.h"
00008 #include "ace/Log_Msg.h"
00009 #include "ace/Malloc_Base.h"
00010 #include "ace/OS_NS_string.h"
00011 
00012 //#define ACE_ENABLE_TIMEPROBES
00013 #include "ace/Timeprobe.h"
00014 
00015 ACE_RCSID (ace,
00016            Message_Block,
00017            "Message_Block.cpp,v 4.105 2006/05/09 07:23:06 jwillemsen Exp")
00018 
00019 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00020 
00021 ACE_ALLOC_HOOK_DEFINE (ACE_Message_Block)
00022 
00023 #if defined (ACE_ENABLE_TIMEPROBES)
00024 
00025 static const char *ACE_MB_Timeprobe_Description[] =
00026 {
00027   "Message_Block::init_i - enter",
00028   "Message_Block::init_i - leave",
00029   "Message_Block::init_i - db alloc",
00030   "Message_Block::init_i - db ctor",
00031   "Data_Block::ctor[1] - enter",
00032   "Data_Block::ctor[1] - leave",
00033   "Data_Block::ctor[2] - enter",
00034   "Data_Block::ctor[2] - leave",
00035   "Data_Block::clone - enter",
00036   "Data_Block::clone - leave"
00037 };
00038 
00039 enum
00040 {
00041   ACE_MESSAGE_BLOCK_INIT_I_ENTER = 3000,
00042   ACE_MESSAGE_BLOCK_INIT_I_LEAVE,
00043   ACE_MESSAGE_BLOCK_INIT_I_DB_ALLOC,
00044   ACE_MESSAGE_BLOCK_INIT_I_DB_CTOR,
00045   ACE_DATA_BLOCK_CTOR1_ENTER,
00046   ACE_DATA_BLOCK_CTOR1_LEAVE,
00047   ACE_DATA_BLOCK_CTOR2_ENTER,
00048   ACE_DATA_BLOCK_CTOR2_LEAVE,
00049   ACE_DATA_BLOCK_CLONE_ENTER,
00050   ACE_DATA_BLOCK_CLONE_LEAVE
00051 };
00052 
00053 
00054 // Setup Timeprobes
00055 ACE_TIMEPROBE_EVENT_DESCRIPTIONS (ACE_MB_Timeprobe_Description,
00056                                   ACE_MESSAGE_BLOCK_INIT_I_ENTER);
00057 
00058 #endif /* ACE_ENABLE_TIMEPROBES */
00059 
00060 void
00061 ACE_Message_Block::data_block (ACE_Data_Block *db)
00062 {
00063   ACE_TRACE ("ACE_Message_Block::data_block");
00064   if (ACE_BIT_DISABLED (this->flags_,
00065                         ACE_Message_Block::DONT_DELETE)
00066       && this->data_block_ != 0)
00067     this->data_block_->release ();
00068 
00069   this->data_block_ = db;
00070 
00071   // Set the read and write pointers in the <Message_Block> to point
00072   // to the buffer in the <ACE_Data_Block>.
00073   this->rd_ptr (this->data_block ()->base ());
00074   this->wr_ptr (this->data_block ()->base ());
00075 }
00076 
00077 int
00078 ACE_Message_Block::copy (const char *buf, size_t n)
00079 {
00080   ACE_TRACE ("ACE_Message_Block::copy");
00081 
00082   /*size_t len = static_cast<size_t> (this->end () - this->wr_ptr ());*/
00083   // Note that for this to work correct, end () *must* be >= mark ().
00084   size_t len = this->space ();
00085 
00086   if (len < n)
00087     return -1;
00088   else
00089     {
00090       (void) ACE_OS::memcpy (this->wr_ptr (),
00091                              buf,
00092                              n);
00093       this->wr_ptr (n);
00094       return 0;
00095     }
00096 }
00097 
00098 int
00099 ACE_Message_Block::copy (const char *buf)
00100 {
00101   ACE_TRACE ("ACE_Message_Block::copy");
00102 
00103   /* size_t len = static_cast<size_t> (this->end () - this->wr_ptr ()); */
00104   // Note that for this to work correct, end() *must* be >= wr_ptr().
00105   size_t len = this->space ();
00106 
00107   size_t buflen = ACE_OS::strlen (buf) + 1;
00108 
00109   if (len < buflen)
00110     return -1;
00111   else
00112     {
00113       (void) ACE_OS::memcpy (this->wr_ptr (),
00114                              buf,
00115                              buflen);
00116       this->wr_ptr (buflen);
00117       return 0;
00118     }
00119 }
00120 
00121 int
00122 ACE_Message_Block::crunch (void)
00123 {
00124   if (this->rd_ptr_ != 0)
00125     {
00126       if (this->rd_ptr_ > this->wr_ptr_)
00127         return -1;
00128 
00129       size_t const len = this->length ();
00130       (void) ACE_OS::memmove (this->base (),
00131                               this->rd_ptr (),
00132                               len);
00133       this->rd_ptr (this->base ());
00134       this->wr_ptr (this->base () + len);
00135     }
00136   return 0;
00137 }
00138 
00139 void
00140 ACE_Data_Block::dump (void) const
00141 {
00142 #if defined (ACE_HAS_DUMP)
00143   ACE_TRACE ("ACE_Data_Block::dump");
00144   ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
00145   ACE_DEBUG ((LM_DEBUG,
00146               ACE_LIB_TEXT ("-----( Data Block )-----\n")
00147               ACE_LIB_TEXT ("type_ = %d\n")
00148               ACE_LIB_TEXT ("cur_size_ = %u\n")
00149               ACE_LIB_TEXT ("max_size_ = %u\n")
00150               ACE_LIB_TEXT ("flags_ = %u\n")
00151               ACE_LIB_TEXT ("base_ = %u\n")
00152               ACE_LIB_TEXT ("locking_strategy_ = %u\n")
00153               ACE_LIB_TEXT ("reference_count_ = %u\n")
00154               ACE_LIB_TEXT ("---------------------------\n"),
00155               this->type_,
00156               this->cur_size_,
00157               this->max_size_,
00158               this->flags_,
00159               this->base_,
00160               this->locking_strategy_,
00161               this->reference_count_));
00162   this->allocator_strategy_->dump ();
00163   ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
00164 #endif /* ACE_HAS_DUMP */
00165 }
00166 
00167 void
00168 ACE_Message_Block::dump (void) const
00169 {
00170 #if defined (ACE_HAS_DUMP)
00171   ACE_TRACE ("ACE_Message_Block::dump");
00172   ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
00173   ACE_DEBUG ((LM_DEBUG,
00174               ACE_LIB_TEXT ("-----( Message Block )-----\n")
00175               ACE_LIB_TEXT ("priority_ = %d\n")
00176               ACE_LIB_TEXT ("next_ = %u\n")
00177               ACE_LIB_TEXT ("prev_ = %u\n")
00178               ACE_LIB_TEXT ("cont_ = %u\n")
00179               ACE_LIB_TEXT ("rd_ptr_ = %u\n")
00180               ACE_LIB_TEXT ("wr_ptr_ = %u\n")
00181               ACE_LIB_TEXT ("---------------------------\n"),
00182               this->priority_,
00183               this->next_,
00184               this->prev_,
00185               this->cont_,
00186               this->rd_ptr_,
00187               this->wr_ptr_));
00188   this->data_block ()->dump ();
00189   ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
00190 #endif /* ACE_HAS_DUMP */
00191 }
00192 
00193 int
00194 ACE_Data_Block::reference_count (void) const
00195 {
00196   if (this->locking_strategy_)
00197     {
00198       // We need to acquire the lock before retrieving the count
00199       ACE_GUARD_RETURN (ACE_Lock, ace_mon, *this->locking_strategy_, 0);
00200 
00201       return this->reference_count_i ();
00202     }
00203 
00204   return this->reference_count_i ();
00205 }
00206 
00207 int
00208 ACE_Data_Block::size (size_t length)
00209 {
00210   ACE_TRACE ("ACE_Data_Block::size");
00211 
00212   if (length <= this->max_size_)
00213     this->cur_size_ = length;
00214   else
00215     {
00216       // We need to resize!
00217       char *buf = 0;
00218       ACE_ALLOCATOR_RETURN (buf,
00219                             (char *) this->allocator_strategy_->malloc (length),
00220                             -1);
00221 
00222       ACE_OS::memcpy (buf,
00223                       this->base_,
00224                       this->cur_size_);
00225       if (ACE_BIT_DISABLED (this->flags_,
00226                             ACE_Message_Block::DONT_DELETE))
00227         this->allocator_strategy_->free ((void *) this->base_);
00228       else
00229         // We now assume ownership.
00230         ACE_CLR_BITS (this->flags_,
00231                       ACE_Message_Block::DONT_DELETE);
00232       this->max_size_ = length;
00233       this->cur_size_ = length;
00234       this->base_ = buf;
00235     }
00236   return 0;
00237 }
00238 
00239 int
00240 ACE_Message_Block::size (size_t length)
00241 {
00242   ACE_TRACE ("ACE_Message_Block::size");
00243 
00244   // Resize the underlying <ACE_Data_Block>.
00245   if (this->data_block ()->size (length) == -1)
00246     return -1;
00247 
00248   return 0;
00249 }
00250 
00251 void
00252 ACE_Message_Block::total_size_and_length (size_t &mb_size,
00253                                           size_t &mb_length) const
00254 {
00255   ACE_TRACE ("ACE_Message_Block::total_size_and_length");
00256 
00257   for (const ACE_Message_Block *i = this;
00258        i != 0;
00259        i = i->cont ())
00260     {
00261       mb_size += i->size ();
00262       mb_length += i->length ();
00263     }
00264 }
00265 
00266 size_t
00267 ACE_Message_Block::total_size (void) const
00268 {
00269   ACE_TRACE ("ACE_Message_Block::total_size");
00270 
00271   size_t size = 0;
00272   for (const ACE_Message_Block *i = this;
00273        i != 0;
00274        i = i->cont ())
00275     size += i->size ();
00276 
00277   return size;
00278 }
00279 
00280 size_t
00281 ACE_Message_Block::total_length (void) const
00282 {
00283   ACE_TRACE ("ACE_Message_Block::total_length");
00284 
00285   size_t length = 0;
00286   for (const ACE_Message_Block *i = this;
00287        i != 0;
00288        i = i->cont ())
00289     length += i->length ();
00290 
00291   return length;
00292 }
00293 
00294 size_t
00295 ACE_Message_Block::total_capacity (void) const
00296 {
00297   ACE_TRACE ("ACE_Message_Block::total_capacity");
00298 
00299   size_t size = 0;
00300 
00301   for (const ACE_Message_Block *i = this;
00302        i != 0;
00303        i = i->cont ())
00304     size += i->capacity ();
00305 
00306   return size;
00307 }
00308 
00309 ACE_Data_Block::ACE_Data_Block (void)
00310   : type_ (ACE_Message_Block::MB_DATA),
00311     cur_size_ (0),
00312     max_size_ (0),
00313     flags_ (ACE_Message_Block::DONT_DELETE),
00314     base_ (0),
00315     allocator_strategy_ (0),
00316     locking_strategy_ (0),
00317     reference_count_ (1),
00318     data_block_allocator_ (0)
00319 {
00320   ACE_TRACE ("ACE_Data_Block::ACE_Data_Block");
00321   ACE_FUNCTION_TIMEPROBE (ACE_DATA_BLOCK_CTOR1_ENTER);
00322 
00323   ACE_ALLOCATOR (this->allocator_strategy_,
00324                  ACE_Allocator::instance ());
00325 
00326   ACE_ALLOCATOR (this->data_block_allocator_,
00327                  ACE_Allocator::instance ());
00328 }
00329 
00330 ACE_Data_Block::ACE_Data_Block (size_t size,
00331                                 ACE_Message_Block::ACE_Message_Type msg_type,
00332                                 const char *msg_data,
00333                                 ACE_Allocator *allocator_strategy,
00334                                 ACE_Lock *locking_strategy,
00335                                 ACE_Message_Block::Message_Flags flags,
00336                                 ACE_Allocator *data_block_allocator)
00337   : type_ (msg_type),
00338     cur_size_ (0),          // Reset later if memory alloc'd ok
00339     max_size_ (0),
00340     flags_ (flags),
00341     base_ (const_cast <char *> (msg_data)),
00342     allocator_strategy_ (allocator_strategy),
00343     locking_strategy_ (locking_strategy),
00344     reference_count_ (1),
00345     data_block_allocator_ (data_block_allocator)
00346 {
00347   ACE_TRACE ("ACE_Data_Block::ACE_Data_Block");
00348   ACE_FUNCTION_TIMEPROBE (ACE_DATA_BLOCK_CTOR2_ENTER);
00349 
00350   // If the user didn't pass one in, let's use the
00351   // <ACE_Allocator::instance>.
00352   if (this->allocator_strategy_ == 0)
00353     ACE_ALLOCATOR (this->allocator_strategy_,
00354                    ACE_Allocator::instance ());
00355 
00356   if (this->data_block_allocator_ == 0)
00357     ACE_ALLOCATOR (this->data_block_allocator_,
00358                    ACE_Allocator::instance ());
00359 
00360   if (msg_data == 0)
00361     ACE_ALLOCATOR (this->base_,
00362                    (char *) this->allocator_strategy_->malloc (size));
00363     // ACE_ALLOCATOR returns on alloc failure...
00364 
00365   // The memory is legit, whether passed in or allocated, so set the size.
00366   this->cur_size_ = this->max_size_ = size;
00367 }
00368 
00369 ACE_Message_Block::ACE_Message_Block (const char *data,
00370                                       size_t size,
00371                                       unsigned long priority)
00372   : flags_ (0),
00373     data_block_ (0)
00374 {
00375   ACE_TRACE ("ACE_Message_Block::ACE_Message_Block");
00376 
00377   if (this->init_i (size,    // size
00378                     MB_DATA, // type
00379                     0,       // cont
00380                     data,    // data
00381                     0,       // allocator
00382                     0,       // locking strategy
00383                     ACE_Message_Block::DONT_DELETE, // flags
00384                     priority, // priority
00385                     ACE_Time_Value::zero,     // execution time
00386                     ACE_Time_Value::max_time, // absolute time of deadline
00387                     0,  // data block
00388                     0,  // data_block allocator
00389                     0) == -1) // message_block allocator
00390     ACE_ERROR ((LM_ERROR,
00391                 ACE_LIB_TEXT ("ACE_Message_Block")));
00392 }
00393 
00394 ACE_Message_Block::ACE_Message_Block (ACE_Allocator *message_block_allocator)
00395   : flags_ (0),
00396     data_block_ (0)
00397 {
00398   ACE_TRACE ("ACE_Message_Block::ACE_Message_Block");
00399 
00400   if (this->init_i (0,       // size
00401                     MB_DATA, // type
00402                     0,       // cont
00403                     0,       // data
00404                     0,       // allocator
00405                     0,       // locking strategy
00406                     ACE_Message_Block::DONT_DELETE, // flags
00407                     0, // priority
00408                     ACE_Time_Value::zero,     // execution time
00409                     ACE_Time_Value::max_time, // absolute time of deadline
00410                     0, // data block
00411                     0, // data_block allocator
00412                     message_block_allocator) == -1) // message_block allocator
00413     ACE_ERROR ((LM_ERROR,
00414                 ACE_LIB_TEXT ("ACE_Message_Block")));
00415 }
00416 
00417 ACE_Message_Block::ACE_Message_Block (size_t size,
00418                                       ACE_Message_Type msg_type,
00419                                       ACE_Message_Block *msg_cont,
00420                                       const char *msg_data,
00421                                       ACE_Allocator *allocator_strategy,
00422                                       ACE_Lock *locking_strategy,
00423                                       unsigned long priority,
00424                                       const ACE_Time_Value &execution_time,
00425                                       const ACE_Time_Value &deadline_time,
00426                                       ACE_Allocator *data_block_allocator,
00427                                       ACE_Allocator *message_block_allocator)
00428   :flags_ (0),
00429    data_block_ (0)
00430 {
00431   ACE_TRACE ("ACE_Message_Block::ACE_Message_Block");
00432 
00433   if (this->init_i (size,
00434                     msg_type,
00435                     msg_cont,
00436                     msg_data,
00437                     allocator_strategy,
00438                     locking_strategy,
00439                     msg_data ? ACE_Message_Block::DONT_DELETE : 0,
00440                     priority,
00441                     execution_time,
00442                     deadline_time,
00443                     0, // data block
00444                     data_block_allocator,
00445                     message_block_allocator) == -1)
00446     ACE_ERROR ((LM_ERROR,
00447                 ACE_LIB_TEXT ("ACE_Message_Block")));
00448 }
00449 
00450 int
00451 ACE_Message_Block::init (size_t size,
00452                          ACE_Message_Type msg_type,
00453                          ACE_Message_Block *msg_cont,
00454                          const char *msg_data,
00455                          ACE_Allocator *allocator_strategy,
00456                          ACE_Lock *locking_strategy,
00457                          unsigned long priority,
00458                          const ACE_Time_Value &execution_time,
00459                          const ACE_Time_Value &deadline_time,
00460                          ACE_Allocator *data_block_allocator,
00461                          ACE_Allocator *message_block_allocator)
00462 {
00463   ACE_TRACE ("ACE_Message_Block::init");
00464 
00465   return this->init_i (size,
00466                        msg_type,
00467                        msg_cont,
00468                        msg_data,
00469                        allocator_strategy,
00470                        locking_strategy,
00471                        msg_data ? ACE_Message_Block::DONT_DELETE : 0,
00472                        priority,
00473                        execution_time,
00474                        deadline_time,
00475                        0,  // data block
00476                        data_block_allocator,
00477                        message_block_allocator);
00478 }
00479 
00480 int
00481 ACE_Message_Block::init (const char *data,
00482                          size_t size)
00483 {
00484   ACE_TRACE ("ACE_Message_Block::init");
00485   // Should we also initialize all the other fields, as well?
00486 
00487   return this->init_i (size,    // size
00488                        MB_DATA, // type
00489                        0,       // cont
00490                        data,    // data
00491                        0,       // allocator
00492                        0,       // locking strategy
00493                        ACE_Message_Block::DONT_DELETE,  // flags
00494                        0,  // priority
00495                        ACE_Time_Value::zero,     // execution time
00496                        ACE_Time_Value::max_time, // absolute time of deadline
00497                        0,  // data block
00498                        0,  // data_block allocator
00499                        0); // message_block allocator
00500 }
00501 
00502 ACE_Message_Block::ACE_Message_Block (size_t size,
00503                                       ACE_Message_Type msg_type,
00504                                       ACE_Message_Block *msg_cont,
00505                                       const char *msg_data,
00506                                       ACE_Allocator *allocator_strategy,
00507                                       ACE_Lock *locking_strategy,
00508                                       Message_Flags flags,
00509                                       unsigned long priority,
00510                                       const ACE_Time_Value &execution_time,
00511                                       const ACE_Time_Value &deadline_time,
00512                                       ACE_Data_Block *db,
00513                                       ACE_Allocator *data_block_allocator,
00514                                       ACE_Allocator *message_block_allocator)
00515   : flags_ (0),
00516     data_block_ (0)
00517 {
00518   ACE_TRACE ("ACE_Message_Block::ACE_Message_Block");
00519 
00520   if (this->init_i (size,
00521                     msg_type,
00522                     msg_cont,
00523                     msg_data,
00524                     allocator_strategy,
00525                     locking_strategy,
00526                     flags,
00527                     priority,
00528                     execution_time,
00529                     deadline_time,
00530                     db,
00531                     data_block_allocator,
00532                     message_block_allocator) == -1)
00533     ACE_ERROR ((LM_ERROR,
00534                 ACE_LIB_TEXT ("ACE_Message_Block")));
00535 }
00536 
00537 ACE_Message_Block::ACE_Message_Block (ACE_Data_Block *data_block,
00538                                       ACE_Message_Block::Message_Flags flags,
00539                                       ACE_Allocator *message_block_allocator)
00540   : flags_ (flags),
00541     data_block_ (0)
00542 {
00543   ACE_TRACE ("ACE_Message_Block::ACE_Message_Block");
00544 
00545   if (this->init_i (0,         // size
00546                     MB_NORMAL, // type
00547                     0,         // cont
00548                     0,         // data
00549                     0,         // allocator
00550                     0,         // locking strategy
00551                     0,         // flags
00552                     0,         // priority
00553                     ACE_Time_Value::zero,     // execution time
00554                     ACE_Time_Value::max_time, // absolute time of deadline
00555                     data_block, // data block
00556                     data_block->data_block_allocator (),
00557                     message_block_allocator) == -1)
00558     ACE_ERROR ((LM_ERROR,
00559                 ACE_LIB_TEXT ("ACE_Message_Block")));
00560 }
00561 
00562 ACE_Message_Block::ACE_Message_Block (const ACE_Message_Block &mb,
00563                                       size_t align)
00564   :flags_ (0),
00565    data_block_ (0)
00566 {
00567   ACE_TRACE ("ACE_Message_Block::ACE_Message_Block");
00568 
00569   if (ACE_BIT_DISABLED (mb.flags_,
00570                         ACE_Message_Block::DONT_DELETE))
00571     {
00572       if (this->init_i (0,         // size
00573                         MB_NORMAL, // type
00574                         0,         // cont
00575                         0,         // data
00576                         0,         // allocator
00577                         0,         // locking strategy
00578                         0,         // flags
00579                         0,         // priority
00580                         ACE_Time_Value::zero,     // execution time
00581                         ACE_Time_Value::max_time, // absolute time of deadline
00582                         mb.data_block ()->duplicate (), // data block
00583                         mb.data_block ()->data_block_allocator (),
00584                         mb.message_block_allocator_) == -1)
00585         ACE_ERROR ((LM_ERROR,
00586                     ACE_LIB_TEXT ("ACE_Message_Block")));
00587 #if !defined (ACE_LACKS_CDR_ALIGNMENT)
00588       // Align ourselves
00589       char *start = ACE_ptr_align_binary (this->base (),
00590                                           align);
00591 #else
00592       char *start = this->base ();
00593 #endif /* ACE_LACKS_CDR_ALIGNMENT */
00594 
00595       // Set our rd & wr pointers
00596       this->rd_ptr (start);
00597       this->wr_ptr (start);
00598 
00599     }
00600   else
00601     {
00602       if (this->init_i (0,         // size
00603                         MB_NORMAL, // type
00604                         0,         // cont
00605                         0,         // data
00606                         0,         // allocator
00607                         0,         // locking strategy
00608                         0,         // flags
00609                         0,         // priority
00610                         ACE_Time_Value::zero,     // execution time
00611                         ACE_Time_Value::max_time, // absolute time of deadline
00612                         mb.data_block ()->clone_nocopy (),// data block
00613                         mb.data_block ()->data_block_allocator (),
00614                         mb.message_block_allocator_) == -1)
00615         ACE_ERROR ((LM_ERROR,
00616                     ACE_LIB_TEXT ("ACE_Message_Block")));
00617 
00618 #if !defined (ACE_LACKS_CDR_ALIGNMENT)
00619       // Align ourselves
00620       char *start = ACE_ptr_align_binary (this->base (),
00621                                           align);
00622 #else
00623       char *start = this->base ();
00624 #endif /* ACE_LACKS_CDR_ALIGNMENT */
00625 
00626       // Set our rd & wr pointers
00627       this->rd_ptr (start);
00628       this->wr_ptr (start);
00629 
00630 #if !defined (ACE_LACKS_CDR_ALIGNMENT)
00631       // Get the alignment offset of the incoming ACE_Message_Block
00632       start = ACE_ptr_align_binary (mb.base (),
00633                                     align);
00634 #else
00635       start = mb.base ();
00636 #endif /* ACE_LACKS_CDR_ALIGNMENT */
00637 
00638       // Actual offset for the incoming message block assuming that it
00639       // is also aligned to the same "align" byte
00640       size_t const wr_offset = mb.wr_ptr_ - (start - mb.base ());
00641 
00642       // Copy wr_offset amount of data in to <this->data_block>
00643       (void) ACE_OS::memcpy (this->wr_ptr (),
00644                              start,
00645                              wr_offset);
00646 
00647       // Dont move the write pointer, just leave it to the application
00648       // to do what it wants
00649 
00650     }
00651 #if defined (ACE_LACKS_CDR_ALIGNMENT)
00652   ACE_UNUSED_ARG (align);
00653 #endif /* ACE_LACKS_CDR_ALIGNMENT */
00654 }
00655 
00656 int
00657 ACE_Message_Block::init_i (size_t size,
00658                            ACE_Message_Type msg_type,
00659                            ACE_Message_Block *msg_cont,
00660                            const char *msg_data,
00661                            ACE_Allocator *allocator_strategy,
00662                            ACE_Lock *locking_strategy,
00663                            Message_Flags flags,
00664                            unsigned long priority,
00665                            const ACE_Time_Value &execution_time,
00666                            const ACE_Time_Value &deadline_time,
00667                            ACE_Data_Block *db,
00668                            ACE_Allocator *data_block_allocator,
00669                            ACE_Allocator *message_block_allocator)
00670 {
00671   ACE_TRACE ("ACE_Message_Block::init_i");
00672   ACE_FUNCTION_TIMEPROBE (ACE_MESSAGE_BLOCK_INIT_I_ENTER);
00673 
00674   this->rd_ptr_ = 0;
00675   this->wr_ptr_ = 0;
00676   this->priority_ = priority;
00677 #if defined (ACE_HAS_TIMED_MESSAGE_BLOCKS)
00678   this->execution_time_ = execution_time;
00679   this->deadline_time_ = deadline_time;
00680 #else
00681   ACE_UNUSED_ARG (execution_time);
00682   ACE_UNUSED_ARG (deadline_time);
00683 #endif /* ACE_HAS_TIMED_MESSAGE_BLOCKS */
00684   this->cont_ = msg_cont;
00685   this->next_ = 0;
00686   this->prev_ = 0;
00687 
00688   this->message_block_allocator_ = message_block_allocator;
00689 
00690   if (this->data_block_ != 0)
00691     {
00692       this->data_block_->release ();
00693       this->data_block_ = 0;
00694     }
00695 
00696   if (db == 0)
00697     {
00698       if (data_block_allocator == 0)
00699         ACE_ALLOCATOR_RETURN (data_block_allocator,
00700                               ACE_Allocator::instance (),
00701                               -1);
00702 
00703       ACE_TIMEPROBE (ACE_MESSAGE_BLOCK_INIT_I_DB_ALLOC);
00704 
00705       // Allocate the <ACE_Data_Block> portion, which is reference
00706       // counted.
00707       ACE_NEW_MALLOC_RETURN (db,
00708                              static_cast<ACE_Data_Block *> (
00709                                data_block_allocator->malloc (sizeof (ACE_Data_Block))),
00710                              ACE_Data_Block (size,
00711                                              msg_type,
00712                                              msg_data,
00713                                              allocator_strategy,
00714                                              locking_strategy,
00715                                              flags,
00716                                              data_block_allocator),
00717                              -1);
00718       ACE_TIMEPROBE (ACE_MESSAGE_BLOCK_INIT_I_DB_CTOR);
00719     }
00720 
00721   // Reset the data_block_ pointer.
00722   this->data_block (db);
00723   // If the data alloc failed, the ACE_Data_Block ctor can't relay
00724   // that directly. Therefore, need to check it explicitly.
00725   if (db->size () < size)
00726     return -1;
00727   return 0;
00728 }
00729 
00730 ACE_Data_Block::~ACE_Data_Block (void)
00731 {
00732   // Sanity check...
00733   ACE_ASSERT (this->reference_count_ <= 1);
00734 
00735   // Just to be safe...
00736   this->reference_count_ = 0;
00737 
00738   if (ACE_BIT_DISABLED (this->flags_,
00739                         ACE_Message_Block::DONT_DELETE))
00740     {
00741       this->allocator_strategy_->free ((void *) this->base_);
00742       this->base_ = 0;
00743     }
00744 }
00745 
00746 ACE_Data_Block *
00747 ACE_Data_Block::release_i (void)
00748 {
00749   ACE_TRACE ("ACE_Data_Block::release_i");
00750 
00751   ACE_ASSERT (this->reference_count_ > 0);
00752 
00753   ACE_Data_Block *result = 0;
00754 
00755   // decrement reference count
00756   --this->reference_count_;
00757 
00758   if (this->reference_count_ == 0)
00759     // this will cause deletion of this
00760     result = 0;
00761   else
00762     result = this;
00763 
00764   return result;
00765 }
00766 
00767 ACE_Data_Block *
00768 ACE_Data_Block::release_no_delete (ACE_Lock *lock)
00769 {
00770   ACE_TRACE ("ACE_Data_Block::release_no_delete");
00771 
00772   ACE_Data_Block *result = 0;
00773   ACE_Lock *lock_to_be_used = 0;
00774 
00775   // Check if we were passed in a lock
00776   if (lock != 0)
00777     {
00778       // Make sure that the lock passed in and our lock are the same
00779       if (lock == this->locking_strategy_)
00780         // In this case no locking is required.
00781         lock_to_be_used = 0;
00782 
00783       // The lock passed in does not match our lock
00784       else
00785         // Lock to be used is our lock
00786         lock_to_be_used = this->locking_strategy_;
00787     }
00788   // This is the case when no lock was passed in
00789   else
00790     // Lock to be used is our lock
00791     lock_to_be_used = this->locking_strategy_;
00792 
00793   // If there's a locking strategy then we need to acquire the lock
00794   // before decrementing the count.
00795   if (lock_to_be_used != 0)
00796     {
00797       ACE_GUARD_RETURN (ACE_Lock, ace_mon, *lock_to_be_used, 0);
00798 
00799       result = this->release_i ();
00800     }
00801   else
00802     result = this->release_i ();
00803 
00804   return result;
00805 }
00806 
00807 ACE_Data_Block *
00808 ACE_Data_Block::release (ACE_Lock *lock)
00809 {
00810   ACE_TRACE ("ACE_Data_Block::release");
00811 
00812   ACE_Allocator *allocator = this->data_block_allocator_;
00813 
00814   ACE_Data_Block *result = this->release_no_delete (lock);
00815 
00816   // We must delete this outside the scope of the locking_strategy_
00817   // since otherwise we'd be trying to "release" through a deleted
00818   // pointer!
00819   if (result == 0)
00820     ACE_DES_FREE (this,
00821                   allocator->free,
00822                   ACE_Data_Block);
00823   return result;
00824 }
00825 
00826 ACE_Message_Block *
00827 ACE_Message_Block::release (void)
00828 {
00829   ACE_TRACE ("ACE_Message_Block::release");
00830 
00831   // We want to hold the data block in a temporary variable because we
00832   // invoked "delete this;" at some point, so using this->data_block_
00833   // could be a bad idea.
00834   ACE_Data_Block *tmp = this->data_block ();
00835 
00836   // This flag is set to 1 when we have to destroy the data_block
00837   int destroy_dblock = 0;
00838 
00839   ACE_Lock *lock = 0;
00840 
00841   // Do we have a valid data block
00842   if (this->data_block ())
00843     {
00844       // Grab the lock that belongs to my data block
00845       lock = this->data_block ()->locking_strategy ();
00846 
00847       // if we have a lock
00848       if (lock != 0)
00849         {
00850           // One guard for all
00851           ACE_GUARD_RETURN (ACE_Lock, ace_mon, *lock, 0);
00852 
00853           // Call non-guarded release with <lock>
00854           destroy_dblock = this->release_i (lock);
00855         }
00856       // This is the case when we have a valid data block but no lock
00857       else
00858         // Call non-guarded release with no lock
00859         destroy_dblock = this->release_i (0);
00860     }
00861   else
00862     // This is the case when we don't even have a valid data block
00863     destroy_dblock = this->release_i (0);
00864 
00865   if (destroy_dblock != 0)
00866     {
00867       ACE_Allocator *allocator = tmp->data_block_allocator ();
00868       ACE_DES_FREE (tmp,
00869                     allocator->free,
00870                     ACE_Data_Block);
00871     }
00872 
00873   return 0;
00874 }
00875 
00876 int
00877 ACE_Message_Block::release_i (ACE_Lock *lock)
00878 {
00879   ACE_TRACE ("ACE_Message_Block::release_i");
00880 
00881   // Free up all the continuation messages.
00882   if (this->cont_)
00883     {
00884       ACE_Message_Block *mb = this->cont_;
00885       ACE_Message_Block *tmp = 0;
00886 
00887       do
00888         {
00889           tmp = mb;
00890           mb = mb->cont_;
00891           tmp->cont_ = 0;
00892 
00893           ACE_Data_Block *db = tmp->data_block ();
00894           if (tmp->release_i (lock) != 0)
00895             {
00896               ACE_Allocator *allocator = db->data_block_allocator ();
00897               ACE_DES_FREE (db,
00898                             allocator->free,
00899                             ACE_Data_Block);
00900             }
00901         }
00902       while (mb);
00903 
00904       this->cont_ = 0;
00905     }
00906 
00907   int result = 0;
00908 
00909   if (ACE_BIT_DISABLED (this->flags_,
00910                         ACE_Message_Block::DONT_DELETE) &&
00911       this->data_block ())
00912     {
00913       if (this->data_block ()->release_no_delete (lock) == 0)
00914         result = 1;
00915       this->data_block_ = 0;
00916     }
00917 
00918   // We will now commit suicide: this object *must* have come from the
00919   // allocator given.
00920   if (this->message_block_allocator_ == 0)
00921     delete this;
00922   else
00923     {
00924       ACE_Allocator *allocator = this->message_block_allocator_;
00925       ACE_DES_FREE (this,
00926                     allocator->free,
00927                     ACE_Message_Block);
00928     }
00929 
00930   return result;
00931 }
00932 
00933 /* static */ ACE_Message_Block *
00934 ACE_Message_Block::release (ACE_Message_Block *mb)
00935 {
00936   ACE_TRACE ("ACE_Message_Block::release");
00937 
00938   if (mb != 0)
00939     return mb->release ();
00940   else
00941     return 0;
00942 }
00943 
00944 ACE_Message_Block::~ACE_Message_Block (void)
00945 {
00946   ACE_TRACE ("ACE_Message_Block::~ACE_Message_Block");
00947 
00948   if (ACE_BIT_DISABLED (this->flags_,
00949                         ACE_Message_Block::DONT_DELETE)&&
00950       this->data_block ())
00951     this->data_block ()->release ();
00952 
00953   this->prev_ = 0;
00954   this->next_ = 0;
00955 }
00956 
00957 ACE_Data_Block *
00958 ACE_Data_Block::duplicate (void)
00959 {
00960   ACE_TRACE ("ACE_Data_Block::duplicate");
00961 
00962   // Create a new <ACE_Message_Block>, but share the <base_> pointer
00963   // data (i.e., don't copy that).
00964   if (this->locking_strategy_)
00965     {
00966       // We need to acquire the lock before incrementing the count.
00967       ACE_GUARD_RETURN (ACE_Lock, ace_mon, *this->locking_strategy_, 0);
00968       ++this->reference_count_;
00969     }
00970   else
00971     ++this->reference_count_;
00972 
00973   return this;
00974 }
00975 
00976 #if defined (ACE_HAS_TIMED_MESSAGE_BLOCKS)
00977 #define ACE_EXECUTION_TIME this->execution_time_
00978 #define ACE_DEADLINE_TIME this->deadline_time_
00979 #else
00980 #define ACE_EXECUTION_TIME ACE_Time_Value::zero
00981 #define ACE_DEADLINE_TIME ACE_Time_Value::max_time
00982 #endif /* ACE_HAS_TIMED_MESSAGE_BLOCKS */
00983 
00984 ACE_Message_Block *
00985 ACE_Message_Block::duplicate (void) const
00986 {
00987   ACE_TRACE ("ACE_Message_Block::duplicate");
00988 
00989   ACE_Message_Block *nb = 0;
00990 
00991   // Create a new <ACE_Message_Block> that contains unique copies of
00992   // the message block fields, but a reference counted duplicate of
00993   // the <ACE_Data_Block>.
00994 
00995   // If there is no allocator, use the standard new and delete calls.
00996   if (this->message_block_allocator_ == 0)
00997     ACE_NEW_RETURN (nb,
00998                     ACE_Message_Block (0, // size
00999                                        ACE_Message_Type (0), // type
01000                                        0, // cont
01001                                        0, // data
01002                                        0, // allocator
01003                                        0, // locking strategy
01004                                        0, // flags
01005                                        this->priority_, // priority
01006                                        ACE_EXECUTION_TIME,
01007                                        ACE_DEADLINE_TIME,
01008                                        // Get a pointer to a
01009                                        // "duplicated" <ACE_Data_Block>
01010                                        // (will simply increment the
01011                                        // reference count).
01012                                        this->data_block ()->duplicate  (),
01013                                        this->data_block ()->data_block_allocator (),
01014                                        this->message_block_allocator_),
01015                   0);
01016   else // Otherwise, use the message_block_allocator passed in.
01017     ACE_NEW_MALLOC_RETURN (nb,
01018                            static_cast<ACE_Message_Block*> (
01019                              message_block_allocator_->malloc (sizeof (ACE_Message_Block))),
01020                            ACE_Message_Block (0, // size
01021                                               ACE_Message_Type (0), // type
01022                                               0, // cont
01023                                               0, // data
01024                                               0, // allocator
01025                                               0, // locking strategy
01026                                               0, // flags
01027                                               this->priority_, // priority
01028                                               ACE_EXECUTION_TIME,
01029                                               ACE_DEADLINE_TIME,
01030                                               // Get a pointer to a
01031                                               // "duplicated" <ACE_Data_Block>
01032                                               // (will simply increment the
01033                                               // reference count).
01034                                               this->data_block ()->duplicate  (),
01035                                               this->data_block ()->data_block_allocator (),
01036                                               this->message_block_allocator_),
01037                            0);
01038 
01039   // Set the read and write pointers in the new <Message_Block> to the
01040   // same relative offset as in the existing <Message_Block>.  Note
01041   // that we are assuming that the data_block()->base() pointer
01042   // doesn't change when it's duplicated.
01043   nb->rd_ptr (this->rd_ptr_);
01044   nb->wr_ptr (this->wr_ptr_);
01045 
01046   // Increment the reference counts of all the continuation messages.
01047   if (this->cont_)
01048     {
01049       nb->cont_ = this->cont_->duplicate ();
01050 
01051       // If things go wrong, release all of our resources and return
01052       // 0.
01053       if (nb->cont_ == 0)
01054         {
01055           nb->release ();
01056           nb = 0;
01057         }
01058     }
01059 
01060   return nb;
01061 }
01062 
01063 ACE_Message_Block *
01064 ACE_Message_Block::duplicate (const ACE_Message_Block *mb)
01065 {
01066   ACE_TRACE ("ACE_Message_Block::duplicate");
01067   if (mb == 0)
01068     return 0;
01069   else
01070     return mb->duplicate ();
01071 }
01072 
01073 ACE_Data_Block *
01074 ACE_Data_Block::clone (ACE_Message_Block::Message_Flags mask) const
01075 {
01076   ACE_TRACE ("ACE_Data_Block::clone");
01077 
01078   ACE_Data_Block *nb = this->clone_nocopy (mask);
01079 
01080   // Copy all of the payload memory into the new object. The new block
01081   // was allocated with max_size_ (and, thus, it's cur_size_ is the same
01082   // as max_size_). Maintain the same "has been written" boundary in the
01083   // new block by only copying cur_size_ bytes.
01084   if (nb != 0)
01085     {
01086       ACE_OS::memcpy (nb->base_,
01087                       this->base_,
01088                       this->cur_size_);
01089     }
01090 
01091   return nb;
01092 }
01093 
01094 ACE_Data_Block *
01095 ACE_Data_Block::clone_nocopy (ACE_Message_Block::Message_Flags mask) const
01096 {
01097   ACE_FUNCTION_TIMEPROBE(ACE_DATA_BLOCK_CLONE_ENTER);
01098 
01099   ACE_TRACE ("ACE_Data_Block::clone_nocopy");
01100 
01101   // You always want to clear this one to prevent memory leaks but you
01102   // might add some others later.
01103   const ACE_Message_Block::Message_Flags always_clear =
01104     ACE_Message_Block::DONT_DELETE;
01105 
01106   ACE_Data_Block *nb = 0;
01107 
01108   ACE_NEW_MALLOC_RETURN (nb,
01109                          static_cast<ACE_Data_Block*> (
01110                            this->data_block_allocator_->malloc (sizeof (ACE_Data_Block))),
01111                          ACE_Data_Block (this->max_size_, // size
01112                                          this->type_,     // type
01113                                          0,               // data
01114                                          this->allocator_strategy_, // allocator
01115                                          this->locking_strategy_, // locking strategy
01116                                          this->flags_,  // flags
01117                                          this->data_block_allocator_),
01118                          0);
01119 
01120 
01121   // Set new flags minus the mask...
01122   nb->clr_flags (mask | always_clear);
01123   return nb;
01124 }
01125 
01126 ACE_Message_Block *
01127 ACE_Message_Block::clone (Message_Flags mask) const
01128 {
01129   ACE_TRACE ("ACE_Message_Block::clone");
01130 
01131   // Get a pointer to a "cloned" <ACE_Data_Block> (will copy the
01132   // values rather than increment the reference count).
01133   ACE_Data_Block *db = this->data_block ()->clone (mask);
01134 
01135   if (db == 0)
01136     return 0;
01137 
01138   ACE_Message_Block *nb = 0;
01139 
01140   if(message_block_allocator_ == 0)
01141     {
01142       ACE_NEW_RETURN (nb,
01143                       ACE_Message_Block (0, // size
01144                                          ACE_Message_Type (0), // type
01145                                          0, // cont
01146                                          0, // data
01147                                          0, // allocator
01148                                          0, // locking strategy
01149                                          0, // flags
01150                                          this->priority_, // priority
01151                                          ACE_EXECUTION_TIME, // execution time
01152                                          ACE_DEADLINE_TIME, // absolute time to deadline
01153                                          // Get a pointer to a
01154                                          // "duplicated" <ACE_Data_Block>
01155                                          // (will simply increment the
01156                                          // reference count).
01157                                          db,
01158                                          db->data_block_allocator (),
01159                                          this->message_block_allocator_),
01160                       0);
01161     }
01162   else
01163     {
01164       // This is the ACE_NEW_MALLOC macro with the return check removed.
01165       // We need to do it this way because if it fails we need to release
01166       // the cloned data block that was created above.  If we used
01167       // ACE_NEW_MALLOC_RETURN, there would be a memory leak because the
01168       // above db pointer would be left dangling.
01169       nb = static_cast<ACE_Message_Block*> (message_block_allocator_->malloc (sizeof (ACE_Message_Block)));
01170       if(nb != 0)
01171         new (nb) ACE_Message_Block (0, // size
01172                                     ACE_Message_Type (0), // type
01173                                     0, // cont
01174                                     0, // data
01175                                     0, // allocator
01176                                     0, // locking strategy
01177                                     0, // flags
01178                                     this->priority_, // priority
01179                                     ACE_EXECUTION_TIME, // execution time
01180                                     ACE_DEADLINE_TIME, // absolute time to deadline
01181                                     db,
01182                                     db->data_block_allocator (),
01183                                     this->message_block_allocator_);
01184     }
01185 
01186   if (nb == 0)
01187     {
01188       db->release ();
01189       return 0;
01190     }
01191 
01192   // Set the read and write pointers in the new <Message_Block> to the
01193   // same relative offset as in the existing <Message_Block>.
01194   nb->rd_ptr (this->rd_ptr_);
01195   nb->wr_ptr (this->wr_ptr_);
01196 
01197   // Clone all the continuation messages if necessary.
01198   if (this->cont () != 0
01199       && (nb->cont_ = this->cont ()->clone (mask)) == 0)
01200     {
01201       nb->release ();
01202       return 0;
01203     }
01204   return nb;
01205 }
01206 
01207 // This is private.
01208 ACE_Message_Block &
01209 ACE_Message_Block::operator= (const ACE_Message_Block &)
01210 {
01211   ACE_TRACE ("ACE_Message_Block::operator=");
01212   return *this;
01213 }
01214 
01215 void
01216 ACE_Data_Block::base (char *msg_data,
01217                       size_t msg_length,
01218                       ACE_Message_Block::Message_Flags msg_flags)
01219 {
01220   if (ACE_BIT_DISABLED (this->flags_,
01221                         ACE_Message_Block::DONT_DELETE))
01222     this->allocator_strategy_->free (this->base_);
01223 
01224   this->max_size_ = msg_length;
01225   this->cur_size_ = msg_length;
01226   this->base_ = msg_data;
01227   this->flags_ = msg_flags;
01228 }
01229 
01230 // ctor
01231 
01232 ACE_Dynamic_Message_Strategy::ACE_Dynamic_Message_Strategy (unsigned long static_bit_field_mask,
01233                                                             unsigned long static_bit_field_shift,
01234                                                             unsigned long dynamic_priority_max,
01235                                                             unsigned long dynamic_priority_offset)
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 }
01245 
01246 // dtor
01247 
01248 ACE_Dynamic_Message_Strategy::~ACE_Dynamic_Message_Strategy (void)
01249 {
01250 }
01251 
01252 // Dump the state of the strategy.
01253 
01254 void
01255 ACE_Dynamic_Message_Strategy::dump (void) const
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 }
01284 
01285 ACE_Deadline_Message_Strategy:: ACE_Deadline_Message_Strategy (unsigned long static_bit_field_mask,
01286                                                                unsigned long static_bit_field_shift,
01287                                                                unsigned long dynamic_priority_max,
01288                                                                unsigned long dynamic_priority_offset)
01289   : ACE_Dynamic_Message_Strategy (static_bit_field_mask,
01290                                   static_bit_field_shift,
01291                                   dynamic_priority_max,
01292                                   dynamic_priority_offset)
01293 {
01294 }
01295 
01296 ACE_Deadline_Message_Strategy::~ACE_Deadline_Message_Strategy (void)
01297 {
01298 }
01299 
01300 void
01301 ACE_Deadline_Message_Strategy::convert_priority (ACE_Time_Value & priority,
01302                                                  const ACE_Message_Block & mb)
01303 {
01304   // Convert absolute time passed in tv to negative time
01305   // to deadline of mb with respect to that absolute time.
01306   priority -= mb.msg_deadline_time ();
01307 }
01308   // dynamic priority conversion function based on time to deadline
01309 
01310 void
01311 ACE_Deadline_Message_Strategy::dump (void) const
01312 {
01313 #if defined (ACE_HAS_DUMP)
01314   ACE_TRACE ("ACE_Deadline_Message_Strategy::dump");
01315 
01316   ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
01317 
01318   ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("ACE_Dynamic_Message_Strategy base class: \n")));
01319   this->ACE_Dynamic_Message_Strategy::dump ();
01320 
01321   ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\nderived class: ACE_Deadline_Message_Strategy\n")));
01322 
01323   ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
01324 #endif /* ACE_HAS_DUMP */
01325 }
01326 
01327 ACE_Laxity_Message_Strategy::ACE_Laxity_Message_Strategy (unsigned long static_bit_field_mask,
01328                                                           unsigned long static_bit_field_shift,
01329                                                           unsigned long dynamic_priority_max,
01330                                                           unsigned long dynamic_priority_offset)
01331   : ACE_Dynamic_Message_Strategy (static_bit_field_mask,
01332                                   static_bit_field_shift,
01333                                   dynamic_priority_max,
01334                                   dynamic_priority_offset)
01335 {
01336 }
01337 
01338 ACE_Laxity_Message_Strategy::~ACE_Laxity_Message_Strategy (void)
01339 {
01340 }
01341 
01342 void
01343 ACE_Laxity_Message_Strategy::convert_priority (ACE_Time_Value & priority,
01344                                                const ACE_Message_Block & mb)
01345 {
01346   // Convert absolute time passed in tv to negative
01347   // laxity of mb with respect to that absolute time.
01348   priority += mb.msg_execution_time ();
01349   priority -= mb.msg_deadline_time ();
01350 }
01351   // dynamic priority conversion function based on laxity
01352 
01353 void
01354 ACE_Laxity_Message_Strategy::dump (void) const
01355 {
01356 #if defined (ACE_HAS_DUMP)
01357   ACE_TRACE ("ACE_Laxity_Message_Strategy::dump");
01358 
01359   ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
01360 
01361   ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("ACE_Dynamic_Message_Strategy base class: \n")));
01362   this->ACE_Dynamic_Message_Strategy::dump ();
01363 
01364   ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\nderived class: ACE_Laxity_Message_Strategy\n")));
01365 
01366   ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
01367 #endif /* ACE_HAS_DUMP */
01368 }
01369   // Dump the state of the strategy.
01370 
01371 ACE_END_VERSIONED_NAMESPACE_DECL

Generated on Thu Nov 9 09:41:56 2006 for ACE by doxygen 1.3.6