From: bangerth Date: Tue, 17 Dec 2013 13:27:26 +0000 (+0000) Subject: Have both subscribe and unsubscribe in the .cc file. This resolves an issue recently... X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5b3da9200047f74731fde78ab0d9d3772d18ced1;p=dealii-svn.git Have both subscribe and unsubscribe in the .cc file. This resolves an issue recently reported on the mailing list of strange crashes where someone links with the debug library but forgets to set -DDEBUG, which leads to a mismatch between what is compiled into their application (coming from the header file) and what they link with (coming from the library) and that leads to a completely unhelpful error message. The resulting code will be slower, but subscribing and unsubscribing is fortunately not something we do all the time. git-svn-id: https://svn.dealii.org/trunk@32039 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/include/deal.II/base/subscriptor.h b/deal.II/include/deal.II/base/subscriptor.h index 44d425865c..f7319cb6b5 100644 --- a/deal.II/include/deal.II/base/subscriptor.h +++ b/deal.II/include/deal.II/base/subscriptor.h @@ -180,20 +180,6 @@ public: void serialize(Archive &ar, const unsigned int version); private: - /** - * Register a subscriber for - * debugging purposes. Called by - * subscribe() in debug mode. - */ - void do_subscribe(const char *id) const; - - /** - * Deregister a subscriber for - * debugging purposes. Called by - * unsubscribe() in debug mode. - */ - void do_unsubscribe(const char *id) const; - /** * The data type used in * #counter_map. @@ -274,38 +260,6 @@ Subscriptor::serialize(Archive &, // documentation of this function } -// If we are in optimized mode, the subscription checking is turned -// off. Therefore, we provide inline definitions of subscribe and -// unsubscribe here. The definitions for debug mode are in -// subscriptor.cc. - -#ifdef DEBUG - -inline void -Subscriptor::subscribe(const char *id) const -{ - do_subscribe(id); -} - - -inline void -Subscriptor::unsubscribe(const char *id) const -{ - do_unsubscribe(id); -} - -#else - -inline void -Subscriptor::subscribe(const char *) const -{} - - -inline void -Subscriptor::unsubscribe(const char *) const -{} - -#endif DEAL_II_NAMESPACE_CLOSE #endif diff --git a/deal.II/source/base/subscriptor.cc b/deal.II/source/base/subscriptor.cc index 505eff1214..422c2311e6 100644 --- a/deal.II/source/base/subscriptor.cc +++ b/deal.II/source/base/subscriptor.cc @@ -142,10 +142,10 @@ Subscriptor &Subscriptor::operator = (const Subscriptor &s) return *this; } -// These are the implementations for debug mode. The optimized -// versions are inlined in the header file. -void Subscriptor::do_subscribe (const char *id) const + +void +Subscriptor::subscribe(const char *id) const { #ifdef DEBUG if (object_info == 0) @@ -153,7 +153,7 @@ void Subscriptor::do_subscribe (const char *id) const Threads::Mutex::ScopedLock lock (subscription_lock); ++counter; -#ifndef DEAL_II_WITH_THREADS +# ifndef DEAL_II_WITH_THREADS const char *const name = (id != 0) ? id : unknown_subscriber; map_iterator it = counter_map.find(name); @@ -162,12 +162,15 @@ void Subscriptor::do_subscribe (const char *id) const else it->second++; -#endif +# endif +#else + (void)id; #endif } -void Subscriptor::do_unsubscribe (const char *id) const +void +Subscriptor::unsubscribe(const char *id) const { #ifdef DEBUG const char *name = (id != 0) ? id : unknown_subscriber; @@ -180,23 +183,27 @@ void Subscriptor::do_unsubscribe (const char *id) const Threads::Mutex::ScopedLock lock (subscription_lock); --counter; -#ifndef DEAL_II_WITH_THREADS +# ifndef DEAL_II_WITH_THREADS map_iterator it = counter_map.find(name); AssertNothrow (it != counter_map.end(), ExcNoSubscriber(object_info->name(), name)); AssertNothrow (it->second > 0, ExcNoSubscriber(object_info->name(), name)); it->second--; -#endif +# endif +#else + (void)id; #endif } + unsigned int Subscriptor::n_subscriptions () const { return counter; } + void Subscriptor::list_subscribers () const { #ifndef DEAL_II_WITH_THREADS