diff options
author | Marc Laukien <marc@zeroc.com> | 2003-04-04 20:37:11 +0000 |
---|---|---|
committer | Marc Laukien <marc@zeroc.com> | 2003-04-04 20:37:11 +0000 |
commit | 5ecd51f857580cd98e226e6f8a75524b6bd239e4 (patch) | |
tree | fdd01122688a49cde784ae95dab3e84965b45e55 | |
parent | Added virtual inheritance from IceUtil::Shared (diff) | |
download | ice-5ecd51f857580cd98e226e6f8a75524b6bd239e4.tar.bz2 ice-5ecd51f857580cd98e226e6f8a75524b6bd239e4.tar.xz ice-5ecd51f857580cd98e226e6f8a75524b6bd239e4.zip |
gcc 2.95.3 fixes
-rw-r--r-- | cpp/CHANGES | 13 | ||||
-rw-r--r-- | cpp/demo/IcePack/hello/Server.cpp | 2 | ||||
-rw-r--r-- | cpp/src/Ice/BasicStream.cpp | 29 | ||||
-rw-r--r-- | cpp/src/Ice/Proxy.cpp | 2 | ||||
-rw-r--r-- | cpp/src/IceSSL/Context.cpp | 4 | ||||
-rw-r--r-- | cpp/src/IceSSL/DHParams.cpp | 4 | ||||
-rw-r--r-- | cpp/src/IceSSL/RSAKeyPair.cpp | 4 | ||||
-rw-r--r-- | cpp/src/IceSSL/RSAPrivateKey.cpp | 4 | ||||
-rw-r--r-- | cpp/src/IceSSL/RSAPublicKey.cpp | 4 | ||||
-rw-r--r-- | cpp/src/IceStorm/TopicI.cpp | 252 | ||||
-rw-r--r-- | cpp/src/IceStorm/TopicI.h | 43 | ||||
-rw-r--r-- | cpp/src/slice2cpp/Gen.cpp | 16 | ||||
-rw-r--r-- | cpp/test/IcePack/deployer/Server.cpp | 2 | ||||
-rw-r--r-- | cpp/test/IcePack/simple/Server.cpp | 2 |
14 files changed, 189 insertions, 192 deletions
diff --git a/cpp/CHANGES b/cpp/CHANGES index 40b7707f9a7..19859425f31 100644 --- a/cpp/CHANGES +++ b/cpp/CHANGES @@ -1,13 +1,18 @@ Changes since version 1.0.1 --------------------------- +- Added support for GCC 2.95.3. + - Several incompatible IceStorm changes: + * Moved the subscribe and unsubscribe operations to the Topic interface. - * Added a type attribute to Topic to support the use of - checkedCast on Topic publisher objects. - * Added an object adapter to host publisher objects, and hence - a new configuration property IceStorm.Publish.Endpoints. + + * Added a type attribute to Topic to support the use of checkedCast + on Topic publisher objects. + + * Added an object adapter to host publisher objects, and hence a new + configuration property IceStorm.Publish.Endpoints. - Added dynamic thread pools, i.e., thread pools that grow and shrink based on a calculated load factor. Please see the section about diff --git a/cpp/demo/IcePack/hello/Server.cpp b/cpp/demo/IcePack/hello/Server.cpp index a4de529f4ae..2e2a0089fa7 100644 --- a/cpp/demo/IcePack/hello/Server.cpp +++ b/cpp/demo/IcePack/hello/Server.cpp @@ -26,7 +26,7 @@ public: }; int -::Server::run(int argc, char* argv[]) +Server::run(int argc, char* argv[]) { Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("Hello"); diff --git a/cpp/src/Ice/BasicStream.cpp b/cpp/src/Ice/BasicStream.cpp index d29ac6b72a4..416af7e2edf 100644 --- a/cpp/src/Ice/BasicStream.cpp +++ b/cpp/src/Ice/BasicStream.cpp @@ -24,17 +24,6 @@ #include <Ice/LocalException.h> #include <Ice/Protocol.h> -// -// COMPILERBUG: Visual C++ .NET doesn't like my template -// specializations. -// - -#if defined(_MSC_VER) && _MSC_VER > 1200 - -# define ice_copy std::copy - -#else - template<typename InputIter, typename OutputIter> void ice_copy(InputIter first, InputIter last, OutputIter result) @@ -50,24 +39,6 @@ ice_copy(std::vector<Ice::Byte>::const_iterator first, std::vector<Ice::Byte>::c memcpy(&*result, &*first, last - first); } -template<> -void -ice_copy(std::string::const_iterator first, std::string::const_iterator last, - std::vector<Ice::Byte>::iterator result) -{ - memcpy(&*result, &*first, last - first); -} - -template<> -void -ice_copy(std::vector<Ice::Byte>::const_iterator first, std::vector<Ice::Byte>::const_iterator last, - std::string::iterator result) -{ - memcpy(&*result, &*first, last - first); -} - -#endif - using namespace std; using namespace Ice; using namespace IceInternal; diff --git a/cpp/src/Ice/Proxy.cpp b/cpp/src/Ice/Proxy.cpp index 69adce28413..72756cd887c 100644 --- a/cpp/src/Ice/Proxy.cpp +++ b/cpp/src/Ice/Proxy.cpp @@ -1187,7 +1187,7 @@ IceDelegateD::Ice::Object::ice_id(const ::Ice::Context& __context) Direct __direct(__current); return __direct.facetServant()->ice_id(__current); } - return false; // To keep the Visual C++ compiler happy. + return string(); // To keep the Visual C++ compiler happy. } FacetPath diff --git a/cpp/src/IceSSL/Context.cpp b/cpp/src/IceSSL/Context.cpp index 7abb269354c..93df03dc7e0 100644 --- a/cpp/src/IceSSL/Context.cpp +++ b/cpp/src/IceSSL/Context.cpp @@ -31,8 +31,8 @@ using namespace std; using namespace Ice; using namespace IceInternal; -void ::IceInternal::incRef(::IceSSL::Context* p) { p->__incRef(); } -void ::IceInternal::decRef(::IceSSL::Context* p) { p->__decRef(); } +void IceInternal::incRef(::IceSSL::Context* p) { p->__incRef(); } +void IceInternal::decRef(::IceSSL::Context* p) { p->__decRef(); } IceSSL::Context::~Context() { diff --git a/cpp/src/IceSSL/DHParams.cpp b/cpp/src/IceSSL/DHParams.cpp index 9de21bbe53b..60e1ed75a50 100644 --- a/cpp/src/IceSSL/DHParams.cpp +++ b/cpp/src/IceSSL/DHParams.cpp @@ -14,8 +14,8 @@ #include <IceSSL/DHParams.h> -void ::IceInternal::incRef(::IceSSL::DHParams* p) { p->__incRef(); } -void ::IceInternal::decRef(::IceSSL::DHParams* p) { p->__decRef(); } +void IceInternal::incRef(::IceSSL::DHParams* p) { p->__incRef(); } +void IceInternal::decRef(::IceSSL::DHParams* p) { p->__decRef(); } IceSSL::DHParams::DHParams(DH* dhParams) : _dhParams(dhParams) diff --git a/cpp/src/IceSSL/RSAKeyPair.cpp b/cpp/src/IceSSL/RSAKeyPair.cpp index 4d5259d0fdb..e68ee15b388 100644 --- a/cpp/src/IceSSL/RSAKeyPair.cpp +++ b/cpp/src/IceSSL/RSAKeyPair.cpp @@ -19,8 +19,8 @@ #include <IceSSL/RSAPublicKey.h> #include <assert.h> -void ::IceInternal::incRef(::IceSSL::RSAKeyPair* p) { p->__incRef(); } -void ::IceInternal::decRef(::IceSSL::RSAKeyPair* p) { p->__decRef(); } +void IceInternal::incRef(::IceSSL::RSAKeyPair* p) { p->__incRef(); } +void IceInternal::decRef(::IceSSL::RSAKeyPair* p) { p->__decRef(); } using std::back_inserter; using std::string; diff --git a/cpp/src/IceSSL/RSAPrivateKey.cpp b/cpp/src/IceSSL/RSAPrivateKey.cpp index 9d869bae391..99e1372247d 100644 --- a/cpp/src/IceSSL/RSAPrivateKey.cpp +++ b/cpp/src/IceSSL/RSAPrivateKey.cpp @@ -20,8 +20,8 @@ #include <IceSSL/Exception.h> #include <assert.h> -void ::IceInternal::incRef(::IceSSL::RSAPrivateKey* p) { p->__incRef(); } -void ::IceInternal::decRef(::IceSSL::RSAPrivateKey* p) { p->__decRef(); } +void IceInternal::incRef(::IceSSL::RSAPrivateKey* p) { p->__incRef(); } +void IceInternal::decRef(::IceSSL::RSAPrivateKey* p) { p->__decRef(); } using std::back_inserter; using std::string; diff --git a/cpp/src/IceSSL/RSAPublicKey.cpp b/cpp/src/IceSSL/RSAPublicKey.cpp index b298c9d9a2e..0a5dc23821d 100644 --- a/cpp/src/IceSSL/RSAPublicKey.cpp +++ b/cpp/src/IceSSL/RSAPublicKey.cpp @@ -20,8 +20,8 @@ #include <IceSSL/Exception.h> #include <assert.h> -void ::IceInternal::incRef(::IceSSL::RSAPublicKey* p) { p->__incRef(); } -void ::IceInternal::decRef(::IceSSL::RSAPublicKey* p) { p->__decRef(); } +void IceInternal::incRef(::IceSSL::RSAPublicKey* p) { p->__incRef(); } +void IceInternal::decRef(::IceSSL::RSAPublicKey* p) { p->__decRef(); } using std::back_inserter; using std::string; diff --git a/cpp/src/IceStorm/TopicI.cpp b/cpp/src/IceStorm/TopicI.cpp index 9b883c48798..7545393fa70 100644 --- a/cpp/src/IceStorm/TopicI.cpp +++ b/cpp/src/IceStorm/TopicI.cpp @@ -19,7 +19,6 @@ #include <IceStorm/Subscriber.h> #include <IceStorm/TraceLevels.h> #include <algorithm> -#include <list> using namespace IceStorm; using namespace std; @@ -29,11 +28,6 @@ namespace IceStorm { // -// A list of Subscribers. -// -typedef std::list<SubscriberPtr> SubscriberList; - -// // The servant has a 1-1 association with a topic. It is used to // receive events from Publishers. // @@ -92,25 +86,66 @@ private: IceStorm::TopicSubscribersPtr _subscribers; }; +} // End namespace IceStorm -// -// Holder for the set of subscribers. -// -class TopicSubscribers : public IceUtil::Shared +IceStorm::TopicSubscribers::TopicSubscribers(const TraceLevelsPtr& traceLevels) : + _traceLevels(traceLevels) { -public: +} - TopicSubscribers(const TraceLevelsPtr& traceLevels) : - _traceLevels(traceLevels) - { - } +IceStorm::TopicSubscribers::~TopicSubscribers() +{ +} - ~TopicSubscribers() +void +IceStorm::TopicSubscribers::add(const SubscriberPtr& subscriber) +{ + Ice::Identity id = subscriber->id(); + + IceUtil::Mutex::Lock sync(_subscribersMutex); + + // + // If a subscriber with this identity is already subscribed + // then mark the subscriber as replaced. + // + // Note that this doesn't actually remove the Subscribe from + // the list of subscribers - it marks the Subscriber as + // replaced, and it's removed on the next event publish. + // + for(SubscriberList::iterator i = _subscribers.begin() ; i != _subscribers.end(); ++i) { + if((*i)->id() == id) + { + // + // This marks the subscriber as invalid. It will be + // removed on the next event publish. + // + (*i)->replace(); + break; + } } + + + // + // Add to the set of subscribers + // + _subscribers.push_back(subscriber); +} - void - add(const SubscriberPtr& subscriber) +// +// Unsubscribe the Subscriber with the given identity. Note that +// this doesn't remove the Subscriber from the list of subscribers +// - it marks the Subscriber as unsubscribed, and it's removed on +// the next event publish. +// +void +IceStorm::TopicSubscribers::remove(const Ice::ObjectPrx& obj) +{ + Ice::Identity id = obj->ice_getIdentity(); + + IceUtil::Mutex::Lock sync(_subscribersMutex); + + for(SubscriberList::iterator i = _subscribers.begin() ; i != _subscribers.end(); ++i) { Ice::Identity id = subscriber->id(); @@ -126,15 +161,12 @@ public: // for(SubscriberList::iterator i = _subscribers.begin() ; i != _subscribers.end(); ++i) { - if((*i)->id() == id) - { - // - // This marks the subscriber as invalid. It will be - // removed on the next event publish. - // - (*i)->replace(); - break; - } + // + // This marks the subscriber as invalid. It will be + // removed on the next event publish. + // + (*i)->unsubscribe(); + return; } // @@ -142,144 +174,102 @@ public: // _subscribers.push_back(subscriber); } - + // // Unsubscribe the subscriber with the given identity. Note that // this doesn't remove the subscriber from the list of subscribers // - it marks the subscriber as unsubscribed, and it's removed on // the next event publish. // - void - remove(const Ice::ObjectPrx& obj) + if(_traceLevels->topic > 0) { - Ice::Identity id = obj->ice_getIdentity(); - - IceUtil::Mutex::Lock sync(_subscribersMutex); - - for(SubscriberList::iterator i = _subscribers.begin() ; i != _subscribers.end(); ++i) - { - if((*i)->id() == id) - { - // - // This marks the subscriber as invalid. It will be - // removed on the next event publish. - // - (*i)->unsubscribe(); - return; - } - } - - // - // If the subscriber was not found then display a diagnostic - // - if(_traceLevels->topic > 0) - { - Ice::Trace out(_traceLevels->logger, _traceLevels->topicCat); - out << id << ": not subscribed."; - } + Ice::Trace out(_traceLevels->logger, _traceLevels->topicCat); + out << id << ": not subscribed."; } +} +// +// TODO: Optimize +// +// It's not strictly necessary to clear the error'd subscribers on +// every publish iteration (if the subscriber validates the state +// before attempting publishing the event). This means more mutex +// locks (due to the state check in the subscriber) - but with the +// advantage that publishes can occur in parallel and less +// subscriber list iterations. +// +void +IceStorm::TopicSubscribers::publish(const Event& event) +{ // - // TODO: Optimize + // Copy of the subscriber list so that event publishing can + // occur in parallel. // - // It's not strictly necessary to clear the error'd subscribers on - // every publish iteration (if the subscriber validates the state - // before attempting publishing the event). This means more mutex - // locks (due to the state check in the subscriber) - but with the - // advantage that publishes can occur in parallel and less - // subscriber list iterations. + // TODO: Find out whether this is a false optimization - how + // expensive is the cost of copying vs. lack of parallelism? // - void - publish(const Event& event) + SubscriberList copy; + { + IceUtil::Mutex::Lock sync(_subscribersMutex); + + // + // Copy of the subscribers that are in error. // // Copy the subscriber list so that event publishing can // occur in parallel. // - // TODO: Find out whether this is a false optimization - how - // expensive is the cost of copying vs. lack of parallelism? + // Erase the inactive subscribers from the _subscribers + // list. Copy the subscribers in error to the error list. // - SubscriberList copy; - + SubscriberList::iterator p = _subscribers.begin(); + while(p != _subscribers.end()) { - IceUtil::Mutex::Lock sync(_subscribersMutex); - - // - // Copy of the subscribers that are in error. - // - SubscriberList e; - - // - // Erase the inactive subscribers from the _subscribers - // list. Copy the subscribers in error to the error list. - // - SubscriberList::iterator p = _subscribers.begin(); - while(p != _subscribers.end()) + if((*p)->inactive()) { - if((*p)->inactive()) - { - if((*p)->error()) - { - e.push_back(*p); - } - - SubscriberList::iterator tmp = p; - ++p; - _subscribers.erase(tmp); - } - else + if((*p)->error()) { - copy.push_back(*p); - ++p; + e.push_back(*p); } + + SubscriberList::iterator tmp = p; + ++p; + _subscribers.erase(tmp); } - - if(!e.empty()) + else { - IceUtil::Mutex::Lock errorSync(_errorMutex); - _error.splice(_error.begin(), e); + copy.push_back(*p); + ++p; } } - - for(SubscriberList::iterator p = copy.begin(); p != copy.end(); ++p) + + if(!e.empty()) { - (*p)->publish(event); + IceUtil::Mutex::Lock errorSync(_errorMutex); + _error.splice(_error.begin(), e); } } - - // - // Clear & return the set of subscribers that are in error. - // - SubscriberList - clearErrorList() + + for(SubscriberList::iterator p = copy.begin(); p != copy.end(); ++p) { - // - // Uses splice for efficiency - // - IceUtil::Mutex::Lock errorSync(_errorMutex); - SubscriberList c; - c.splice(c.begin(), _error); - return c; + (*p)->publish(event); } +} -private: - - TraceLevelsPtr _traceLevels; - - // - // TODO: Should there be a map from identity to subscriber? - // - IceUtil::Mutex _subscribersMutex; - SubscriberList _subscribers; - +// +// Clear & return the set of subscribers that are in error. +// +SubscriberList +IceStorm::TopicSubscribers::clearErrorList() +{ // - // Set of subscribers that have encountered an error. + // Uses splice for efficiency // - IceUtil::Mutex _errorMutex; - SubscriberList _error; -}; - -} // End namespace IceStorm + IceUtil::Mutex::Lock errorSync(_errorMutex); + SubscriberList c; + c.splice(c.begin(), _error); + return c; +} // // Incoming events from publishers. diff --git a/cpp/src/IceStorm/TopicI.h b/cpp/src/IceStorm/TopicI.h index 8f65e3f4cce..87e9ae2b1e5 100644 --- a/cpp/src/IceStorm/TopicI.h +++ b/cpp/src/IceStorm/TopicI.h @@ -19,25 +19,56 @@ #include <IceStorm/IceStormInternal.h> #include <IceStorm/IdentityLinkDict.h> #include <IceStorm/SubscriberFactory.h> +#include <list> namespace IceStorm { -// -// Forward declarations. -// +struct Event; + class TopicSubscribers; typedef IceUtil::Handle<TopicSubscribers> TopicSubscribersPtr; class TraceLevels; typedef IceUtil::Handle<TraceLevels> TraceLevelsPtr; +class Subscriber; +typedef IceUtil::Handle<Subscriber> SubscriberPtr; + class SubscriberFactory; typedef IceUtil::Handle<SubscriberFactory> SubscriberFactoryPtr; -// -// TopicInternal implementation. -// +typedef std::list<SubscriberPtr> SubscriberList; + +class TopicSubscribers : public IceUtil::Shared +{ +public: + + TopicSubscribers(const TraceLevelsPtr&); + virtual ~TopicSubscribers(); + + void add(const SubscriberPtr&); + void remove(const Ice::ObjectPrx&); + void publish(const Event& event); + SubscriberList clearErrorList(); + +private: + + TraceLevelsPtr _traceLevels; + + // + // TODO: Should there be a map from identity to subscriber? + // + IceUtil::Mutex _subscribersMutex; + SubscriberList _subscribers; + + // + // Set of subscribers that have encountered an error. + // + IceUtil::Mutex _errorMutex; + SubscriberList _error; +}; + class TopicI : public TopicInternal, public IceUtil::RecMutex { public: diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp index a4924302bf7..9b64c588518 100644 --- a/cpp/src/slice2cpp/Gen.cpp +++ b/cpp/src/slice2cpp/Gen.cpp @@ -2539,7 +2539,7 @@ Slice::Gen::ObjectVisitor::visitOperation(const OperationPtr& p) } writeAllocateCode(C, inParams, 0); writeUnmarshalCode(C, inParams, 0); - C << nl << classScopedAMD << '_' << name << "Ptr __cb = new ::IceAsync" << classScopedAMD << '_' << name + C << nl << classScopedAMD << '_' << name << "Ptr __cb = new IceAsync" << classScopedAMD << '_' << name << "(__in);"; C << nl << "try"; C << sb; @@ -2694,7 +2694,7 @@ Slice::Gen::IceInternalVisitor::visitClassDefStart(const ClassDefPtr& p) << scoped << "Prx& d)"; C << sb; C << nl << "d = 0;"; - C << nl << "if(b)"; + C << nl << "if(b.get())"; // COMPILERFIX: 'if(b)' doesn't work for GCC 2.95.3. C << sb; C << nl << "d = dynamic_cast< ::IceProxy" << scoped << "*>(b.get());"; C << nl << "if(!d && b->ice_isA(\"" << p->scoped() << "\"))"; @@ -3400,7 +3400,7 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p) H << sp << nl << "typedef ::IceUtil::Handle< " << classScopedAMI << '_' << name << "> " << classNameAMI << '_' << name << "Ptr;"; - C << sp << nl << "void" << nl << classScopedAMI << '_' << name << "::__response(bool __ok)"; + C << sp << nl << "void" << nl << classScopedAMI.substr(2) << '_' << name << "::__response(bool __ok)"; C << sb; writeAllocateCode(C, outParams, ret); C << nl << "try"; @@ -3606,7 +3606,7 @@ Slice::Gen::AsyncImplVisitor::visitOperation(const OperationPtr& p) H << nl << "virtual void ice_exception();"; H << eb << ';'; - C << sp << nl << "::IceAsync" << classScopedAMD << '_' << name << "::" << classNameAMD << '_' << name + C << sp << nl << "IceAsync" << classScopedAMD << '_' << name << "::" << classNameAMD << '_' << name << "(::IceInternal::Incoming& in) :"; C.inc(); C << nl << "IncomingAsync(in)"; @@ -3614,7 +3614,7 @@ Slice::Gen::AsyncImplVisitor::visitOperation(const OperationPtr& p) C << sb; C << eb; - C << sp << nl << "void" << nl << "::IceAsync" << classScopedAMD << '_' << name << "::ice_response(" + C << sp << nl << "void" << nl << "IceAsync" << classScopedAMD << '_' << name << "::ice_response(" << paramsDecl << ')'; C << sb; C << nl << "if(!_finished)"; @@ -3636,7 +3636,7 @@ Slice::Gen::AsyncImplVisitor::visitOperation(const OperationPtr& p) C << eb; C << eb; - C << sp << nl << "void" << nl << "::IceAsync" << classScopedAMD << '_' << name + C << sp << nl << "void" << nl << "IceAsync" << classScopedAMD << '_' << name << "::ice_exception(const ::Ice::Exception& ex)"; C << sb; C << nl << "if(!_finished)"; @@ -3668,7 +3668,7 @@ Slice::Gen::AsyncImplVisitor::visitOperation(const OperationPtr& p) C << eb; C << eb; - C << sp << nl << "void" << nl << "::IceAsync" << classScopedAMD << '_' << name + C << sp << nl << "void" << nl << "IceAsync" << classScopedAMD << '_' << name << "::ice_exception(const ::std::exception& ex)"; C << sb; C << nl << "if(!_finished)"; @@ -3677,7 +3677,7 @@ Slice::Gen::AsyncImplVisitor::visitOperation(const OperationPtr& p) C << eb; C << eb; - C << sp << nl << "void" << nl << "::IceAsync" << classScopedAMD << '_' << name + C << sp << nl << "void" << nl << "IceAsync" << classScopedAMD << '_' << name << "::ice_exception()"; C << sb; C << nl << "if(!_finished)"; diff --git a/cpp/test/IcePack/deployer/Server.cpp b/cpp/test/IcePack/deployer/Server.cpp index 78398ec8a85..6b9b794453c 100644 --- a/cpp/test/IcePack/deployer/Server.cpp +++ b/cpp/test/IcePack/deployer/Server.cpp @@ -27,7 +27,7 @@ public: }; int -::Server::run(int argc, char* argv[]) +Server::run(int argc, char* argv[]) { Ice::PropertiesPtr properties = communicator()->getProperties(); diff --git a/cpp/test/IcePack/simple/Server.cpp b/cpp/test/IcePack/simple/Server.cpp index 049cb293b26..70419758ee7 100644 --- a/cpp/test/IcePack/simple/Server.cpp +++ b/cpp/test/IcePack/simple/Server.cpp @@ -26,7 +26,7 @@ public: }; int -::Server::run(int argc, char* argv[]) +Server::run(int argc, char* argv[]) { Ice::StringSeq args = Ice::argsToStringSeq(argc, argv); args = communicator()->getProperties()->parseCommandLineOptions("TestAdapter", args); |