Skip to content

Commit

Permalink
* Made Barrier's interface still available with no_karl but not corre…
Browse files Browse the repository at this point in the history
…ct functionality. This is useful for GAMS supporting no_karl with minimal changes
  • Loading branch information
jredmondson committed Mar 8, 2019
1 parent 6f91034 commit 5880bea
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
10 changes: 6 additions & 4 deletions include/madara/knowledge/containers/Barrier.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@

#ifndef _MADARA_NO_KARL_

#include <sstream>

#include "Barrier.h"
Expand Down Expand Up @@ -69,7 +67,9 @@ madara::knowledge::containers::Barrier::Barrier(const Barrier& rhs)
variable_(rhs.variable_),
id_(rhs.id_),
participants_(rhs.participants_),
#ifndef _MADARA_NO_KARL_
aggregate_barrier_(rhs.aggregate_barrier_),
#endif
variable_name_(rhs.variable_name_)
{
}
Expand All @@ -88,7 +88,9 @@ void madara::knowledge::containers::Barrier::operator=(const Barrier& rhs)
this->participants_ = rhs.participants_;
this->settings_ = rhs.settings_;
this->variable_ = rhs.variable_;
#ifndef _MADARA_NO_KARL_
this->aggregate_barrier_ = rhs.aggregate_barrier_;
#endif
this->variable_name_ = rhs.variable_name_;
}
}
Expand Down Expand Up @@ -124,7 +126,9 @@ void madara::knowledge::containers::Barrier::build_aggregate_barrier(void)
}
}

#ifndef _MADARA_NO_KARL_
aggregate_barrier_ = context_->compile(buffer.str());
#endif

madara_logger_log(context_->get_logger(), logger::LOG_MAJOR,
"Barrier::build_aggregate_barrier: building barrier string of %s\n",
Expand Down Expand Up @@ -489,5 +493,3 @@ bool madara::knowledge::containers::Barrier::is_false_(void) const
{
return is_false();
}

#endif // _MADARA_NO_KARL_
11 changes: 7 additions & 4 deletions include/madara/knowledge/containers/Barrier.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
#ifndef _MADARA_CONTAINERS_BARRIER_H_
#define _MADARA_CONTAINERS_BARRIER_H_

#ifndef _MADARA_NO_KARL_

#include <vector>
#include <string>
#include "madara/LockType.h"
Expand Down Expand Up @@ -311,7 +309,12 @@ class MADARA_EXPORT Barrier : public BaseContainer
**/
inline type barrier_result(void) const
{
#ifndef _MADARA_NO_KARL_
return context_->evaluate(aggregate_barrier_, no_harm).to_integer();
#else
// note this means that barriers are always successful if no_karl=1
return type(1);
#endif
}

/**
Expand Down Expand Up @@ -344,10 +347,12 @@ class MADARA_EXPORT Barrier : public BaseContainer
**/
size_t participants_;

#ifndef _MADARA_NO_KARL_
/**
* Expression for aggregating barrier in one atomic operation
**/
CompiledExpression aggregate_barrier_;
#endif

/**
* Settings we'll use for all evaluations
Expand All @@ -363,6 +368,4 @@ class MADARA_EXPORT Barrier : public BaseContainer
}
}

#endif // _MADARA_NO_KARL_

#endif // _MADARA_CONTAINERS_BARRIER_H_

0 comments on commit 5880bea

Please sign in to comment.