]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Remove debug mode guards in Subscriptor::(un)subscribe.
authorJean-Paul Pelteret <jppelteret@gmail.com>
Mon, 30 Apr 2018 20:48:31 +0000 (22:48 +0200)
committerJean-Paul Pelteret <jppelteret@gmail.com>
Sun, 15 Jul 2018 18:19:21 +0000 (20:19 +0200)
The aim here is to prevent a race conditions not appearing in debug mode
and but only in release mode (which would actually mak debugging
harder). The drawback is that in release mode subscription, which does
not occur too frequently, is now more expensive.

source/base/subscriptor.cc

index 9a6b95ebc1b8fdcee988c68399c9cec6cf194249..a02237ee484db6d564baaa3788604821a3d5b9ac 100644 (file)
@@ -156,7 +156,6 @@ Subscriptor::operator=(Subscriptor &&s) noexcept
 void
 Subscriptor::subscribe(const char *id) const
 {
-#ifdef DEBUG
   if (object_info == nullptr)
     object_info = &typeid(*this);
   ++counter;
@@ -173,16 +172,12 @@ Subscriptor::subscribe(const char *id) const
 
   else
     it->second++;
-#else
-  (void)id;
-#endif
 }
 
 
 void
 Subscriptor::unsubscribe(const char *id) const
 {
-#ifdef DEBUG
   const char *name = (id != nullptr) ? id : unknown_subscriber;
   AssertNothrow(counter > 0, ExcNoSubscriber(object_info->name(), name));
   // This is for the case that we do
@@ -202,9 +197,6 @@ Subscriptor::unsubscribe(const char *id) const
   AssertNothrow(it->second > 0, ExcNoSubscriber(object_info->name(), name));
 
   it->second--;
-#else
-  (void)id;
-#endif
 }
 
 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.