summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles E. Rolke <chug@apache.org>2011-01-10 20:43:56 +0000
committerCharles E. Rolke <chug@apache.org>2011-01-10 20:43:56 +0000
commitc95e40580ef57d5a1e36e9105ae18dbffe3c3de8 (patch)
tree9ea688597fefd0ae6ab1c42b8b99d142f42b082f
parent02d83427237f6929595692fa12b9a614e523ccda (diff)
downloadqpid-python-c95e40580ef57d5a1e36e9105ae18dbffe3c3de8.tar.gz
.NET Binding for Qpid Messaging, in every .NET object that keeps
a reference to unmanaged memory: * Function Cleanup() is deleted and cleanup is moved to Finalizer. * Destructor calls Finalizer. * Finalizer takes a lock before deleting unmanaged memory. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1057350 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--cpp/bindings/qpid/dotnet/src/Address.cpp10
-rw-r--r--cpp/bindings/qpid/dotnet/src/Address.h3
-rw-r--r--cpp/bindings/qpid/dotnet/src/Connection.cpp10
-rw-r--r--cpp/bindings/qpid/dotnet/src/Connection.h3
-rw-r--r--cpp/bindings/qpid/dotnet/src/FailoverUpdates.cpp10
-rw-r--r--cpp/bindings/qpid/dotnet/src/FailoverUpdates.h3
-rw-r--r--cpp/bindings/qpid/dotnet/src/Message.cpp21
-rw-r--r--cpp/bindings/qpid/dotnet/src/Message.h3
-rw-r--r--cpp/bindings/qpid/dotnet/src/Receiver.cpp21
-rw-r--r--cpp/bindings/qpid/dotnet/src/Receiver.h3
-rw-r--r--cpp/bindings/qpid/dotnet/src/Sender.cpp22
-rw-r--r--cpp/bindings/qpid/dotnet/src/Sender.h3
-rw-r--r--cpp/bindings/qpid/dotnet/src/Session.cpp22
-rw-r--r--cpp/bindings/qpid/dotnet/src/Session.h3
14 files changed, 40 insertions, 97 deletions
diff --git a/cpp/bindings/qpid/dotnet/src/Address.cpp b/cpp/bindings/qpid/dotnet/src/Address.cpp
index b78eb8243e..b688d973ed 100644
--- a/cpp/bindings/qpid/dotnet/src/Address.cpp
+++ b/cpp/bindings/qpid/dotnet/src/Address.cpp
@@ -187,21 +187,15 @@ namespace Messaging {
// Destructor
Address::~Address()
{
- Cleanup();
+ this->!Address();
}
// Finalizer
Address::!Address()
{
- Cleanup();
- }
-
+ msclr::lock lk(this);
- // Destroys kept object
- // TODO: add lock
- void Address::Cleanup()
- {
if (NULL != addressp)
{
delete addressp;
diff --git a/cpp/bindings/qpid/dotnet/src/Address.h b/cpp/bindings/qpid/dotnet/src/Address.h
index 0fa5df97db..e5a00d8f11 100644
--- a/cpp/bindings/qpid/dotnet/src/Address.h
+++ b/cpp/bindings/qpid/dotnet/src/Address.h
@@ -43,9 +43,6 @@ namespace Messaging {
public ref class Address
{
private:
- // Kept object deletion code
- void Cleanup();
-
// The kept object in the Messaging C++ DLL
::qpid::messaging::Address * addressp;
diff --git a/cpp/bindings/qpid/dotnet/src/Connection.cpp b/cpp/bindings/qpid/dotnet/src/Connection.cpp
index d0c5bc9ac5..69ace7db52 100644
--- a/cpp/bindings/qpid/dotnet/src/Connection.cpp
+++ b/cpp/bindings/qpid/dotnet/src/Connection.cpp
@@ -140,21 +140,15 @@ namespace Messaging {
// Destructor
Connection::~Connection()
{
- Cleanup();
+ this->!Connection();
}
// Finalizer
Connection::!Connection()
{
- Cleanup();
- }
-
+ msclr::lock lk(this);
- // Destroys kept object
- // TODO: add lock
- void Connection::Cleanup()
- {
if (NULL != connectionp)
{
delete connectionp;
diff --git a/cpp/bindings/qpid/dotnet/src/Connection.h b/cpp/bindings/qpid/dotnet/src/Connection.h
index 23d0679fd5..f9b62d4a08 100644
--- a/cpp/bindings/qpid/dotnet/src/Connection.h
+++ b/cpp/bindings/qpid/dotnet/src/Connection.h
@@ -45,9 +45,6 @@ namespace Messaging {
// The kept object in the Messaging C++ DLL
::qpid::messaging::Connection * connectionp;
- // Kept object deletion code
- void Cleanup();
-
public:
Connection(System::String ^ url);
diff --git a/cpp/bindings/qpid/dotnet/src/FailoverUpdates.cpp b/cpp/bindings/qpid/dotnet/src/FailoverUpdates.cpp
index a931e2d670..d34474f2c4 100644
--- a/cpp/bindings/qpid/dotnet/src/FailoverUpdates.cpp
+++ b/cpp/bindings/qpid/dotnet/src/FailoverUpdates.cpp
@@ -64,21 +64,15 @@ namespace Messaging {
// Destructor
FailoverUpdates::~FailoverUpdates()
{
- Cleanup();
+ this->!FailoverUpdates();
}
// Finalizer
FailoverUpdates::!FailoverUpdates()
{
- Cleanup();
- }
-
+ msclr::lock lk(this);
- // Destroys kept object
- // TODO: add lock
- void FailoverUpdates::Cleanup()
- {
if (NULL != failoverupdatesp)
{
delete failoverupdatesp;
diff --git a/cpp/bindings/qpid/dotnet/src/FailoverUpdates.h b/cpp/bindings/qpid/dotnet/src/FailoverUpdates.h
index bc668d616c..1dd92b8688 100644
--- a/cpp/bindings/qpid/dotnet/src/FailoverUpdates.h
+++ b/cpp/bindings/qpid/dotnet/src/FailoverUpdates.h
@@ -42,9 +42,6 @@ namespace Messaging {
// The kept object in the Messaging C++ DLL
::qpid::messaging::FailoverUpdates * failoverupdatesp;
- // Kept object deletion code
- void Cleanup();
-
public:
FailoverUpdates(Connection ^ connection);
diff --git a/cpp/bindings/qpid/dotnet/src/Message.cpp b/cpp/bindings/qpid/dotnet/src/Message.cpp
index 07a1026b21..fe7825134d 100644
--- a/cpp/bindings/qpid/dotnet/src/Message.cpp
+++ b/cpp/bindings/qpid/dotnet/src/Message.cpp
@@ -219,14 +219,20 @@ namespace Messaging {
// Destructor
Message::~Message()
{
- Cleanup();
+ this->!Message();
}
// Finalizer
Message::!Message()
{
- Cleanup();
+ msclr::lock lk(this);
+
+ if (NULL != messagep)
+ {
+ delete messagep;
+ messagep = NULL;
+ }
}
// Copy constructor
@@ -251,17 +257,6 @@ namespace Messaging {
}
}
- // Destroys kept object
- // TODO: add lock
- void Message::Cleanup()
- {
- if (NULL != messagep)
- {
- delete messagep;
- messagep = NULL;
- }
- }
-
// Property
void Message::SetProperty(System::String ^ name, System::Object ^ value)
{
diff --git a/cpp/bindings/qpid/dotnet/src/Message.h b/cpp/bindings/qpid/dotnet/src/Message.h
index cbe8cfc7ab..b92cc4200b 100644
--- a/cpp/bindings/qpid/dotnet/src/Message.h
+++ b/cpp/bindings/qpid/dotnet/src/Message.h
@@ -47,9 +47,6 @@ namespace Messaging {
{
private:
- // Kept object deletion code
- void Cleanup();
-
// The kept object in the Messaging C++ DLL
::qpid::messaging::Message * messagep;
diff --git a/cpp/bindings/qpid/dotnet/src/Receiver.cpp b/cpp/bindings/qpid/dotnet/src/Receiver.cpp
index 4c9062866d..3c0d79b393 100644
--- a/cpp/bindings/qpid/dotnet/src/Receiver.cpp
+++ b/cpp/bindings/qpid/dotnet/src/Receiver.cpp
@@ -72,14 +72,20 @@ namespace Messaging {
// Destructor
Receiver::~Receiver()
{
- Cleanup();
+ this->!Receiver();
}
// Finalizer
Receiver::!Receiver()
{
- Cleanup();
+ msclr::lock lk(this);
+
+ if (NULL != receiverp)
+ {
+ delete receiverp;
+ receiverp = NULL;
+ }
}
@@ -107,17 +113,6 @@ namespace Messaging {
}
- // Destroys kept object
- // TODO: add lock
- void Receiver::Cleanup()
- {
- if (NULL != receiverp)
- {
- delete receiverp;
- receiverp = NULL;
- }
- }
-
//
// Get(message)
//
diff --git a/cpp/bindings/qpid/dotnet/src/Receiver.h b/cpp/bindings/qpid/dotnet/src/Receiver.h
index 123c266b55..e9912a61dd 100644
--- a/cpp/bindings/qpid/dotnet/src/Receiver.h
+++ b/cpp/bindings/qpid/dotnet/src/Receiver.h
@@ -54,9 +54,6 @@ namespace Messaging {
// The session that created this Receiver
Session ^ parentSession;
- // Kept object deletion code
- void Cleanup();
-
// The kept object in the Messaging C++ DLL
::qpid::messaging::Receiver * receiverp;
diff --git a/cpp/bindings/qpid/dotnet/src/Sender.cpp b/cpp/bindings/qpid/dotnet/src/Sender.cpp
index a051026e71..584075ef5f 100644
--- a/cpp/bindings/qpid/dotnet/src/Sender.cpp
+++ b/cpp/bindings/qpid/dotnet/src/Sender.cpp
@@ -67,16 +67,23 @@ namespace Messaging {
// Destructor
Sender::~Sender()
{
- Cleanup();
+ this->!Sender();
}
// Finalizer
Sender::!Sender()
{
- Cleanup();
+ msclr::lock lk(this);
+
+ if (NULL != senderp)
+ {
+ delete senderp;
+ senderp = NULL;
+ }
}
+
// Copy constructor
Sender::Sender(const Sender ^ sender)
: parentSession(sender->parentSession)
@@ -101,17 +108,6 @@ namespace Messaging {
}
- // Destroys kept object
- // TODO: add lock
- void Sender::Cleanup()
- {
- if (NULL != senderp)
- {
- delete senderp;
- senderp = NULL;
- }
- }
-
//
// Send(msg)
//
diff --git a/cpp/bindings/qpid/dotnet/src/Sender.h b/cpp/bindings/qpid/dotnet/src/Sender.h
index e8ba227c06..0e90a9f4a4 100644
--- a/cpp/bindings/qpid/dotnet/src/Sender.h
+++ b/cpp/bindings/qpid/dotnet/src/Sender.h
@@ -55,9 +55,6 @@ namespace Messaging {
// The session that created this Sender
Session ^ parentSession;
- // Kept object deletion code
- void Cleanup();
-
public:
// unmanaged clone
Sender(const ::qpid::messaging::Sender & s,
diff --git a/cpp/bindings/qpid/dotnet/src/Session.cpp b/cpp/bindings/qpid/dotnet/src/Session.cpp
index b6d00b433f..880331c588 100644
--- a/cpp/bindings/qpid/dotnet/src/Session.cpp
+++ b/cpp/bindings/qpid/dotnet/src/Session.cpp
@@ -72,16 +72,23 @@ namespace Messaging {
// Destructor
Session::~Session()
{
- Cleanup();
+ this->!Session();
}
// Finalizer
Session::!Session()
{
- Cleanup();
+ msclr::lock lk(this);
+
+ if (NULL != sessionp)
+ {
+ delete sessionp;
+ sessionp = NULL;
+ }
}
+
// Copy constructor
Session::Session(const Session ^ session)
: parentConnectionp(session->parentConnectionp)
@@ -107,17 +114,6 @@ namespace Messaging {
}
- // Destroys kept object
- // TODO: add lock
- void Session::Cleanup()
- {
- if (NULL != sessionp)
- {
- delete sessionp;
- sessionp = NULL;
- }
- }
-
void Session::Close()
{
System::Exception ^ newException = nullptr;
diff --git a/cpp/bindings/qpid/dotnet/src/Session.h b/cpp/bindings/qpid/dotnet/src/Session.h
index aa42cf5668..7eaad8a0a5 100644
--- a/cpp/bindings/qpid/dotnet/src/Session.h
+++ b/cpp/bindings/qpid/dotnet/src/Session.h
@@ -61,9 +61,6 @@ namespace Messaging {
// The connection that created this session
Connection ^ parentConnectionp;
- // Kept object deletion code
- void Cleanup();
-
public:
// unmanaged clone