Skip to content
Snippets Groups Projects
Commit b238fcf4 authored by Dr. Felix Tobias Schindler's avatar Dr. Felix Tobias Schindler
Browse files

[common.crtp] make it threadsafe

* according to Rene
parent fa09266c
No related branches found
No related tags found
No related merge requests found
......@@ -6,8 +6,9 @@
#ifndef DUNE_STUFF_COMMON_CRTP_HH
#define DUNE_STUFF_COMMON_CRTP_HH
#include <atomic>
#include "exceptions.hh"
#include <dune/common/bartonnackmanifcheck.hh>
#ifdef CHECK_CRTP
#undef CHECK_CRTP
......@@ -20,14 +21,14 @@
#define CHECK_CRTP(dummy)
#else
/**
* This macro is essentially a slightly modified copy of the CHECK_INTERFACE_IMPLEMENTATION macro.
* This macro is essentially a thread safe variant of the CHECK_INTERFACE_IMPLEMENTATION macro from dune-common.
*/
#define CHECK_CRTP(__interface_method_to_call__) \
{ \
static bool call = false; \
static std::atomic<bool> call(false); \
if (call) \
DUNE_THROW_COLORFULLY(Dune::Stuff::Exception::CRTP_check_failed, \
"The derived class does not implement a required method!"); \
"The derived class does not implement the required method!"); \
call = true; \
try { \
(__interface_method_to_call__); \
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment