summaryrefslogtreecommitdiff
path: root/ace
diff options
context:
space:
mode:
authorcoryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-08-08 03:11:08 +0000
committercoryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-08-08 03:11:08 +0000
commit5bb71ce4bfd4ec788b34a1e465b5fb10ec7e90b3 (patch)
tree35985dabecb288b528a95873d3fa3679bd07dd9a /ace
parentc11ce37933a18f6f233b0c12b0674910832544f4 (diff)
downloadATCD-5bb71ce4bfd4ec788b34a1e465b5fb10ec7e90b3.tar.gz
ChangeLogTag:Fri Aug 7 21:39:26 1998 Carlos O'Ryan <coryan@cs.wustl.edu>
Diffstat (limited to 'ace')
-rw-r--r--ace/INET_Addr.cpp5
-rw-r--r--ace/Message_Block.cpp144
-rw-r--r--ace/Message_Block.h27
-rw-r--r--ace/Message_Block.i13
4 files changed, 139 insertions, 50 deletions
diff --git a/ace/INET_Addr.cpp b/ace/INET_Addr.cpp
index 222ecc33c07..d18f5526181 100644
--- a/ace/INET_Addr.cpp
+++ b/ace/INET_Addr.cpp
@@ -58,9 +58,8 @@ ACE_INET_Addr::operator == (const ACE_INET_Addr &sap) const
ACE_TRACE ("ACE_INET_Addr::operator ==");
return this->inet_addr_.sin_port == sap.inet_addr_.sin_port
- && ACE_OS::memcmp ((void *) &this->inet_addr_.sin_addr,
- (void *) &sap.inet_addr_.sin_addr,
- sizeof (this->inet_addr_.sin_addr)) == 0;
+ && (this->inet_addr_.sin_addr.S_un.S_addr
+ == sap.inet_addr_.sin_addr.S_un.S_addr);
}
ACE_INET_Addr::ACE_INET_Addr (void)
diff --git a/ace/Message_Block.cpp b/ace/Message_Block.cpp
index 52f1917c1d2..6b82657604d 100644
--- a/ace/Message_Block.cpp
+++ b/ace/Message_Block.cpp
@@ -4,6 +4,9 @@
#include "ace/Message_Block.h"
#include "ace/Synch_T.h"
+// #define ACE_ENABLE_TIMEPROBES
+#include "ace/Timeprobe.h"
+
#if !defined (__ACE_INLINE__)
#include "ace/Message_Block.i"
#endif /* __ACE_INLINE__ */
@@ -12,6 +15,39 @@ ACE_RCSID(ace, Message_Block, "$Id$")
ACE_ALLOC_HOOK_DEFINE(ACE_Message_Block)
+#if defined (ACE_ENABLE_TIMEPROBES)
+
+static const char *ACE_MB_Timeprobe_Description[] =
+{
+ "Message_Block::init_i - enter",
+ "Message_Block::init_i - leave",
+ "Message_Block::init_i - db alloc",
+ "Message_Block::init_i - db ctor",
+ "Data_Block::ctor[1] - enter",
+ "Data_Block::ctor[1] - leave",
+ "Data_Block::ctor[2] - enter",
+ "Data_Block::ctor[2] - leave"
+};
+
+enum
+{
+ ACE_MESSAGE_BLOCK_INIT_I_ENTER = 3000,
+ ACE_MESSAGE_BLOCK_INIT_I_LEAVE,
+ ACE_MESSAGE_BLOCK_INIT_I_DB_ALLOC,
+ ACE_MESSAGE_BLOCK_INIT_I_DB_CTOR,
+ ACE_DATA_BLOCK_CTOR1_ENTER,
+ ACE_DATA_BLOCK_CTOR1_LEAVE,
+ ACE_DATA_BLOCK_CTOR2_ENTER,
+ ACE_DATA_BLOCK_CTOR2_LEAVE
+};
+
+
+// Setup Timeprobes
+ACE_TIMEPROBE_EVENT_DESCRIPTIONS (ACE_MB_Timeprobe_Description,
+ ACE_MESSAGE_BLOCK_INIT_I_ENTER);
+
+#endif /* ACE_ENABLE_TIMEPROBES */
+
void
ACE_Message_Block::data_block (ACE_Data_Block *db)
{
@@ -174,9 +210,11 @@ ACE_Data_Block::ACE_Data_Block (void)
base_ (0),
allocator_strategy_ (0),
locking_strategy_ (0),
- reference_count_ (1)
+ reference_count_ (1),
+ data_block_allocator_ (0)
{
ACE_TRACE ("ACE_Data_Block::ACE_Data_Block");
+ ACE_FUNCTION_TIMEPROBE (ACE_DATA_BLOCK_CTOR1_ENTER);
}
ACE_Data_Block::ACE_Data_Block (size_t size,
@@ -184,7 +222,8 @@ ACE_Data_Block::ACE_Data_Block (size_t size,
const char *msg_data,
ACE_Allocator *allocator_strategy,
ACE_Lock *locking_strategy,
- ACE_Message_Block::Message_Flags flags)
+ ACE_Message_Block::Message_Flags flags,
+ ACE_Allocator *data_block_allocator)
: type_ (msg_type),
cur_size_ (size),
max_size_ (size),
@@ -192,15 +231,20 @@ ACE_Data_Block::ACE_Data_Block (size_t size,
base_ ((char *) msg_data),
allocator_strategy_ (allocator_strategy),
locking_strategy_ (locking_strategy),
- reference_count_ (1)
+ reference_count_ (1),
+ data_block_allocator_ (data_block_allocator)
{
ACE_TRACE ("ACE_Data_Block::ACE_Data_Block");
+ ACE_FUNCTION_TIMEPROBE (ACE_DATA_BLOCK_CTOR2_ENTER);
// If the user didn't pass one in, let's use the
// <ACE_Allocator::instance>.
if (this->allocator_strategy_ == 0)
ACE_ALLOCATOR (this->allocator_strategy_, ACE_Allocator::instance ());
+ if (this->data_block_allocator_ == 0)
+ ACE_ALLOCATOR (this->data_block_allocator_, ACE_Allocator::instance ());
+
if (msg_data == 0)
ACE_ALLOCATOR (this->base_,
(char *) this->allocator_strategy_->malloc (size));
@@ -223,7 +267,8 @@ ACE_Message_Block::ACE_Message_Block (const char *data,
0, // priority
ACE_Time_Value::zero, // execution time
ACE_Time_Value::max_time, // absolute time of deadline
- 0) == -1) // data block
+ 0, // data block
+ 0) == -1) // data_block allocator
ACE_ERROR ((LM_ERROR, ASYS_TEXT ("ACE_Message_Block")));
}
@@ -241,7 +286,8 @@ ACE_Message_Block::ACE_Message_Block (void)
0, // priority
ACE_Time_Value::zero, // execution time
ACE_Time_Value::max_time, // absolute time of deadline
- 0) == -1) // data block
+ 0, // data block
+ 0) == -1) // data_block allocator
ACE_ERROR ((LM_ERROR, ASYS_TEXT ("ACE_Message_Block")));
}
@@ -253,7 +299,8 @@ ACE_Message_Block::ACE_Message_Block (size_t size,
ACE_Lock *locking_strategy,
u_long priority,
const ACE_Time_Value & execution_time,
- const ACE_Time_Value & deadline_time)
+ const ACE_Time_Value & deadline_time,
+ ACE_Allocator *data_block_allocator)
{
ACE_TRACE ("ACE_Message_Block::ACE_Message_Block");
@@ -267,7 +314,8 @@ ACE_Message_Block::ACE_Message_Block (size_t size,
priority,
execution_time,
deadline_time,
- 0) == -1) // data block
+ 0, // data block
+ data_block_allocator) == -1)
ACE_ERROR ((LM_ERROR, ASYS_TEXT ("ACE_Message_Block")));
}
@@ -280,7 +328,8 @@ ACE_Message_Block::init (size_t size,
ACE_Lock *locking_strategy,
u_long priority,
const ACE_Time_Value & execution_time,
- const ACE_Time_Value & deadline_time)
+ const ACE_Time_Value & deadline_time,
+ ACE_Allocator *data_block_allocator)
{
ACE_TRACE ("ACE_Message_Block::init");
@@ -294,7 +343,8 @@ ACE_Message_Block::init (size_t size,
priority,
execution_time,
deadline_time,
- 0); // data block
+ 0, // data block
+ data_block_allocator);
}
int
@@ -314,7 +364,8 @@ ACE_Message_Block::init (const char *data,
0, // priority
ACE_Time_Value::zero, // execution time
ACE_Time_Value::max_time, // absolute time of deadline
- 0); // data block
+ 0, // data block
+ 0);
}
ACE_Message_Block::ACE_Message_Block (size_t size,
@@ -327,7 +378,8 @@ ACE_Message_Block::ACE_Message_Block (size_t size,
u_long priority,
const ACE_Time_Value & execution_time,
const ACE_Time_Value & deadline_time,
- ACE_Data_Block *db)
+ ACE_Data_Block *db,
+ ACE_Allocator *data_block_allocator)
{
ACE_TRACE ("ACE_Message_Block::ACE_Message_Block");
@@ -341,7 +393,8 @@ ACE_Message_Block::ACE_Message_Block (size_t size,
priority,
execution_time,
deadline_time,
- db) == -1)
+ db,
+ data_block_allocator) == -1)
ACE_ERROR ((LM_ERROR, ASYS_TEXT ("ACE_Message_Block")));
}
@@ -359,7 +412,8 @@ ACE_Message_Block::ACE_Message_Block (ACE_Data_Block *data_block)
0, // priority
ACE_Time_Value::zero, // execution time
ACE_Time_Value::max_time, // absolute time of deadline
- data_block) == -1) // data block
+ data_block,
+ data_block->data_block_allocator ()) == -1) // data block
ACE_ERROR ((LM_ERROR, ASYS_TEXT ("ACE_Message_Block")));
}
@@ -374,9 +428,11 @@ ACE_Message_Block::init_i (size_t size,
u_long priority,
const ACE_Time_Value & execution_time,
const ACE_Time_Value & deadline_time,
- ACE_Data_Block *db)
+ ACE_Data_Block *db,
+ ACE_Allocator *data_block_allocator)
{
ACE_TRACE ("ACE_Message_Block::init_i");
+ ACE_FUNCTION_TIMEPROBE (ACE_MESSAGE_BLOCK_INIT_I_ENTER);
this->priority_ = priority;
this->execution_time_ = execution_time;
@@ -387,16 +443,28 @@ ACE_Message_Block::init_i (size_t size,
this->data_block_ = 0;
if (db == 0)
- // Allocate the <ACE_Data_Block> portion, which is reference
- // counted.
- ACE_NEW_RETURN (db,
- ACE_Data_Block (size,
- msg_type,
- msg_data,
- allocator_strategy,
- locking_strategy,
- flags),
- -1);
+ {
+ if (data_block_allocator == 0)
+ ACE_ALLOCATOR_RETURN (data_block_allocator,
+ ACE_Allocator::instance (), -1);
+
+ ACE_TIMEPROBE (ACE_MESSAGE_BLOCK_INIT_I_DB_ALLOC);
+
+ // Allocate the <ACE_Data_Block> portion, which is reference
+ // counted.
+ ACE_NEW_MALLOC_RETURN (db,
+ ACE_static_cast(ACE_Data_Block*,
+ data_block_allocator->malloc (sizeof (ACE_Data_Block))),
+ ACE_Data_Block (size,
+ msg_type,
+ msg_data,
+ allocator_strategy,
+ locking_strategy,
+ flags,
+ data_block_allocator),
+ -1);
+ ACE_TIMEPROBE (ACE_MESSAGE_BLOCK_INIT_I_DB_CTOR);
+ }
// Reset the data_block_ pointer.
this->data_block (db);
@@ -446,6 +514,7 @@ ACE_Data_Block::release (ACE_Lock *lock)
ACE_Data_Block *result = 0;
ACE_Lock *lock_to_be_used = 0;
+ ACE_Allocator *allocator = this->data_block_allocator_;
// Check if we were passed in a lock
if (lock != 0)
@@ -480,7 +549,7 @@ ACE_Data_Block::release (ACE_Lock *lock)
// since otherwise we'd be trying to "release" through a deleted
// pointer!
if (result == 0)
- delete this;
+ ACE_DES_FREE (this, allocator->free, ACE_Data_Block);
return result;
}
@@ -622,7 +691,8 @@ ACE_Message_Block::duplicate (void) const
// "duplicated" <ACE_Data_Block>
// (will simply increment the
// reference count).
- this->data_block ()->duplicate ()), // data block
+ this->data_block ()->duplicate (),
+ this->data_block ()->data_block_allocator ()),
0);
// Set the read and write pointers in the new <Message_Block> to the
@@ -671,14 +741,17 @@ ACE_Data_Block::clone (ACE_Message_Block::Message_Flags mask) const
ACE_Data_Block *nb;
- ACE_NEW_RETURN (nb,
- ACE_Data_Block (this->max_size_, // size
- this->type_, // type
- 0, // data
- this->allocator_strategy_, // allocator
- this->locking_strategy_, // locking strategy
- this->flags_), // flags
- 0);
+ ACE_NEW_MALLOC_RETURN (nb,
+ ACE_static_cast(ACE_Data_Block*,
+ this->data_block_allocator_->malloc (sizeof (ACE_Data_Block))),
+ ACE_Data_Block (this->max_size_, // size
+ this->type_, // type
+ 0, // data
+ this->allocator_strategy_, // allocator
+ this->locking_strategy_, // locking strategy
+ this->flags_, // flags
+ this->data_block_allocator_),
+ 0);
// Copy all of the payload memory into the new object.
ACE_OS::memcpy (nb->base_, this->base_, this->max_size_);
@@ -712,7 +785,8 @@ ACE_Message_Block::clone (Message_Flags mask) const
this->priority_, // priority
this->execution_time_, // execution time
this->deadline_time_, // absolute time to deadline
- db); // data_block
+ db, // data_block
+ db->data_block_allocator ());
if (nb == 0)
{
db->release ();
diff --git a/ace/Message_Block.h b/ace/Message_Block.h
index de140cb3d49..728a6e34834 100644
--- a/ace/Message_Block.h
+++ b/ace/Message_Block.h
@@ -116,7 +116,8 @@ public:
ACE_Lock *locking_strategy = 0,
u_long priority = 0,
const ACE_Time_Value & execution_time = ACE_Time_Value::zero,
- const ACE_Time_Value & deadline_time = ACE_Time_Value::max_time);
+ const ACE_Time_Value & deadline_time = ACE_Time_Value::max_time,
+ ACE_Allocator *data_block_allocator = 0);
// Create an initialized message of type <type> containing <size>
// bytes. The <cont> argument initializes the continuation field in
// the <Message_Block>. If <data> == 0 then we create and own the
@@ -127,6 +128,9 @@ public:
// counting) from race conditions. Note that the <size> of the
// <Message_Block> will be <size>, but the <length> will be 0 until
// <wr_ptr> is set.
+ // The <data_block_allocator> is use to allocate the data blocks
+ // while the <allocator_strategy> is used to allocate the buffers
+ // contained by those.
int init (const char *data,
size_t size = 0);
@@ -143,7 +147,8 @@ public:
ACE_Lock *locking_strategy = 0,
u_long priority = 0,
const ACE_Time_Value & execution_time = ACE_Time_Value::zero,
- const ACE_Time_Value & deadline_time = ACE_Time_Value::max_time);
+ const ACE_Time_Value & deadline_time = ACE_Time_Value::max_time,
+ ACE_Allocator *data_block_allocator = 0);
// Create an initialized message of type <type> containing <size>
// bytes. The <cont> argument initializes the continuation field in
// the <Message_Block>. If <data> == 0 then we create and own the
@@ -154,6 +159,9 @@ public:
// counting) from race conditions. Note that the <size> of the
// <Message_Block> will be <size>, but the <length> will be 0 until
// <wr_ptr> is set.
+ // The <data_block_allocator> is use to allocate the data blocks
+ // while the <allocator_strategy> is used to allocate the buffers
+ // contained by those.
virtual ~ACE_Message_Block (void);
// Delete all the resources held in the message.
@@ -334,7 +342,8 @@ private:
u_long priority,
const ACE_Time_Value & execution_time,
const ACE_Time_Value & deadline_time,
- ACE_Data_Block *db);
+ ACE_Data_Block *db,
+ ACE_Allocator *data_block_allocator);
// Perform the actual initialization.
ACE_Message_Block *release_i (ACE_Lock *lock);
@@ -350,7 +359,8 @@ private:
u_long priority,
const ACE_Time_Value & execution_time,
const ACE_Time_Value & deadline_time,
- ACE_Data_Block *db);
+ ACE_Data_Block *db,
+ ACE_Allocator *data_block_allocator);
// Perform the actual initialization.
char *rd_ptr_;
@@ -409,7 +419,8 @@ public:
const char *msg_data,
ACE_Allocator *allocator_strategy,
ACE_Lock *locking_strategy,
- ACE_Message_Block::Message_Flags flags);
+ ACE_Message_Block::Message_Flags flags,
+ ACE_Allocator *data_block_allocator);
// Initialize.
virtual ~ACE_Data_Block (void);
@@ -476,6 +487,9 @@ public:
int reference_count (void) const;
// Get the current reference count.
+ ACE_Allocator *data_block_allocator (void);
+ // Get the allocator used to create this object
+
private:
ACE_Data_Block *release_i (void);
// Internal release implementation
@@ -513,6 +527,9 @@ private:
// shared by all owners of the <Data_Block>'s data, i.e., all the
// <ACE_Message_Block>s.
+ ACE_Allocator *data_block_allocator_;
+ // The allocator use to destroy ourselves.
+
// = Disallow these operations.
ACE_Data_Block &operator= (const ACE_Data_Block &);
ACE_Data_Block (const ACE_Data_Block &);
diff --git a/ace/Message_Block.i b/ace/Message_Block.i
index 4f58c137176..4b3eb0ae957 100644
--- a/ace/Message_Block.i
+++ b/ace/Message_Block.i
@@ -60,6 +60,12 @@ ACE_Data_Block::flags (void) const
return this->flags_;
}
+ACE_INLINE ACE_Allocator*
+ACE_Data_Block::data_block_allocator (void)
+{
+ return this->data_block_allocator_;
+}
+
ACE_INLINE ACE_Message_Block::Message_Flags
ACE_Message_Block::set_flags (ACE_Message_Block::Message_Flags more_flags)
{
@@ -519,10 +525,3 @@ ACE_Laxity_Message_Strategy::convert_priority (ACE_Time_Value & priority,
priority -= mb.msg_deadline_time ();
}
// dynamic priority conversion function based on laxity
-
-
-
-
-
-
-