diff options
author | Mark Spruiell <mes@zeroc.com> | 2002-12-19 21:57:28 +0000 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2002-12-19 21:57:28 +0000 |
commit | a15264b4c7f270181b0fea3db6b30896596f4ec1 (patch) | |
tree | 567b96885aabe74126edc1ac64610f9c209f6d24 /cpp | |
parent | Fixed a deadlock in adapter activation (diff) | |
download | ice-a15264b4c7f270181b0fea3db6b30896596f4ec1.tar.bz2 ice-a15264b4c7f270181b0fea3db6b30896596f4ec1.tar.xz ice-a15264b4c7f270181b0fea3db6b30896596f4ec1.zip |
adding destroy flag
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/demo/Freeze/library/LibraryI.cpp | 31 | ||||
-rw-r--r-- | cpp/demo/Freeze/library/LibraryI.h | 1 | ||||
-rw-r--r-- | cpp/demo/Freeze/phonebook/PhoneBookI.cpp | 45 | ||||
-rw-r--r-- | cpp/demo/Freeze/phonebook/PhoneBookI.h | 1 |
4 files changed, 76 insertions, 2 deletions
diff --git a/cpp/demo/Freeze/library/LibraryI.cpp b/cpp/demo/Freeze/library/LibraryI.cpp index f24f413033c..8eaed395b37 100644 --- a/cpp/demo/Freeze/library/LibraryI.cpp +++ b/cpp/demo/Freeze/library/LibraryI.cpp @@ -18,7 +18,7 @@ using namespace std; BookI::BookI(const LibraryIPtr& library) : - _library(library) + _library(library), _destroyed(false) { } @@ -31,6 +31,13 @@ BookI::destroy(const Ice::Current&) { IceUtil::RWRecMutex::RLock sync(*this); + if(_destroyed) + { + throw Ice::ObjectNotExistException(__FILE__, __LINE__); + } + + _destroyed = true; + try { _library->remove(description); @@ -52,6 +59,13 @@ BookI::destroy(const Ice::Current&) ::BookDescription BookI::getBookDescription(const Ice::Current&) const { + IceUtil::RWRecMutex::RLock sync(*this); + + if(_destroyed) + { + throw Ice::ObjectNotExistException(__FILE__, __LINE__); + } + // Immutable return description; } @@ -61,6 +75,11 @@ BookI::getRenterName(const Ice::Current&) const { IceUtil::RWRecMutex::RLock sync(*this); + if(_destroyed) + { + throw Ice::ObjectNotExistException(__FILE__, __LINE__); + } + if(rentalCustomerName.empty()) { throw BookNotRentedException(); @@ -73,6 +92,11 @@ BookI::rentBook(const ::std::string& name, const Ice::Current&) { IceUtil::RWRecMutex::WLock sync(*this); + if(_destroyed) + { + throw Ice::ObjectNotExistException(__FILE__, __LINE__); + } + if(!rentalCustomerName.empty()) { throw BookRentedException(); @@ -85,6 +109,11 @@ BookI::returnBook(const Ice::Current&) { IceUtil::RWRecMutex::WLock sync(*this); + if(_destroyed) + { + throw Ice::ObjectNotExistException(__FILE__, __LINE__); + } + if(rentalCustomerName.empty()) { throw BookNotRentedException(); diff --git a/cpp/demo/Freeze/library/LibraryI.h b/cpp/demo/Freeze/library/LibraryI.h index e46405932fa..5c6301eb952 100644 --- a/cpp/demo/Freeze/library/LibraryI.h +++ b/cpp/demo/Freeze/library/LibraryI.h @@ -65,6 +65,7 @@ public: private: LibraryIPtr _library; + bool _destroyed; }; #endif diff --git a/cpp/demo/Freeze/phonebook/PhoneBookI.cpp b/cpp/demo/Freeze/phonebook/PhoneBookI.cpp index 74b7ff6c962..3cc1ccf2ee1 100644 --- a/cpp/demo/Freeze/phonebook/PhoneBookI.cpp +++ b/cpp/demo/Freeze/phonebook/PhoneBookI.cpp @@ -20,7 +20,8 @@ using namespace Freeze; ContactI::ContactI(const PhoneBookIPtr& phoneBook, const EvictorPtr& evictor) : _phoneBook(phoneBook), - _evictor(evictor) + _evictor(evictor), + _destroyed(false) { } @@ -34,6 +35,12 @@ string ContactI::getName(const Ice::Current&) const { IceUtil::RWRecMutex::RLock sync(*this); + + if(_destroyed) + { + throw Ice::ObjectNotExistException(__FILE__, __LINE__); + } + return name; } @@ -42,6 +49,11 @@ ContactI::setName(const string& name, const Ice::Current&) { IceUtil::RWRecMutex::WLock sync(*this); + if(_destroyed) + { + throw Ice::ObjectNotExistException(__FILE__, __LINE__); + } + assert(!_identity.name.empty()); _phoneBook->move(_identity, this->name, name); this->name = name; @@ -51,6 +63,12 @@ string ContactI::getAddress(const Ice::Current&) const { IceUtil::RWRecMutex::RLock sync(*this); + + if(_destroyed) + { + throw Ice::ObjectNotExistException(__FILE__, __LINE__); + } + return address; } @@ -58,6 +76,12 @@ void ContactI::setAddress(const string& address, const Ice::Current&) { IceUtil::RWRecMutex::WLock sync(*this); + + if(_destroyed) + { + throw Ice::ObjectNotExistException(__FILE__, __LINE__); + } + this->address = address; } @@ -65,6 +89,12 @@ string ContactI::getPhone(const Ice::Current&) const { IceUtil::RWRecMutex::RLock sync(*this); + + if(_destroyed) + { + throw Ice::ObjectNotExistException(__FILE__, __LINE__); + } + return phone; } @@ -72,6 +102,12 @@ void ContactI::setPhone(const string& phone, const Ice::Current&) { IceUtil::RWRecMutex::WLock sync(*this); + + if(_destroyed) + { + throw Ice::ObjectNotExistException(__FILE__, __LINE__); + } + this->phone = phone; } @@ -80,6 +116,13 @@ ContactI::destroy(const Ice::Current&) { IceUtil::RWRecMutex::RLock sync(*this); + if(_destroyed) + { + throw Ice::ObjectNotExistException(__FILE__, __LINE__); + } + + _destroyed = true; + try { assert(!_identity.name.empty()); diff --git a/cpp/demo/Freeze/phonebook/PhoneBookI.h b/cpp/demo/Freeze/phonebook/PhoneBookI.h index ae3d7e44fd5..6563968aa0e 100644 --- a/cpp/demo/Freeze/phonebook/PhoneBookI.h +++ b/cpp/demo/Freeze/phonebook/PhoneBookI.h @@ -51,6 +51,7 @@ private: PhoneBookIPtr _phoneBook; Freeze::EvictorPtr _evictor; Ice::Identity _identity; + bool _destroyed; }; class PhoneBookI : public PhoneBook, public IceUtil::RWRecMutex |