#include <deal.II/base/exceptions.h>
#include <deal.II/base/smartpointer.h>
+#include <deal.II/base/subscriptor.h>
#include <deal.II/base/thread_local_storage.h>
#include <cmath>
#include <deal.II/base/config.h>
-#include <deal.II/base/subscriptor.h>
+#include <deal.II/base/exceptions.h>
+
+#include <atomic>
+#include <typeinfo>
DEAL_II_NAMESPACE_OPEN
* The Smartpointer is invalidated when the object pointed to is destroyed
* or moved from.
*/
- bool pointed_to_object_is_alive;
+ std::atomic<bool> pointed_to_object_is_alive;
};
* subscriber may be identified by text supplied as @p identifier.
*/
void
- subscribe(bool *const validity, const char *identifier = nullptr) const;
+ subscribe(std::atomic<bool> *const validity,
+ const char * identifier = nullptr) const;
/**
* Unsubscribes a user from the object.
* the one supplied to subscribe().
*/
void
- unsubscribe(bool *const validity, const char *identifier = nullptr) const;
+ unsubscribe(std::atomic<bool> *const validity,
+ const char * identifier = nullptr) const;
/**
* Return the present number of subscriptions to this object. This allows to
* In this vector, we store pointers to the validity bool in the SmartPointer
* objects that subscribe to this class.
*/
- mutable std::vector<bool *> validity_pointers;
+ mutable std::vector<std::atomic<bool> *> validity_pointers;
/**
* Pointer to the typeinfo object of this object, from which we can later
#include <deal.II/base/config.h>
#include <deal.II/base/smartpointer.h>
+#include <deal.II/base/subscriptor.h>
#include <string>
void
-Subscriptor::subscribe(bool *const validity, const char *id) const
+Subscriptor::subscribe(std::atomic<bool> *const validity, const char *id) const
{
std::lock_guard<std::mutex> lock(mutex);
void
-Subscriptor::unsubscribe(bool *const validity, const char *id) const
+Subscriptor::unsubscribe(std::atomic<bool> *const validity,
+ const char * id) const
{
const char *name = (id != nullptr) ? id : unknown_subscriber;
AssertNothrow(counter > 0, ExcNoSubscriber(object_info->name(), name));
initlog();
- Subscriptor subscriptor;
- bool dummy_a;
+ Subscriptor subscriptor;
+ std::atomic<bool> dummy_a;
subscriptor.subscribe(&dummy_a, "a");
subscriptor.unsubscribe(&dummy_a, "b");
subscriptor.unsubscribe(&dummy_a, "a");
DEAL::
--------------------------------------------------------
An error occurred in file <subscriptor.cc> in function
- void dealii::Subscriptor::unsubscribe(bool*, const char*) const
+ void dealii::Subscriptor::unsubscribe(std::atomic<bool>*, const char*) const
The violated condition was:
it != counter_map.end()
Additional information:
DEAL::
--------------------------------------------------------
An error occurred in file <subscriptor.cc> in function
- void dealii::Subscriptor::unsubscribe(bool*, const char*) const
+ void dealii::Subscriptor::unsubscribe(std::atomic<bool>*, const char*) const
The violated condition was:
validity_ptr_it != validity_pointers.end()
Additional information:
--- /dev/null
+
+DEAL::Exception: ExcNoSubscriber(object_info->name(), name)
+DEAL::
+--------------------------------------------------------
+An error occurred in file <subscriptor.cc> in function
+ void dealii::Subscriptor::unsubscribe(std::atomic<bool> *const, const char *) const
+The violated condition was:
+ it != counter_map.end()
+Additional information:
+ No subscriber with identifier <b> subscribes to this object of class N6dealii11SubscriptorE. Consequently, it cannot be unsubscribed.
+--------------------------------------------------------
+
+DEAL::Exception: ExcMessage( "This Subscriptor object does not know anything about the supplied pointer!")
+DEAL::
+--------------------------------------------------------
+An error occurred in file <subscriptor.cc> in function
+ void dealii::Subscriptor::unsubscribe(std::atomic<bool> *const, const char *) const
+The violated condition was:
+ validity_ptr_it != validity_pointers.end()
+Additional information:
+ This Subscriptor object does not know anything about the supplied pointer!
+--------------------------------------------------------
+