proxygen
AnnotatedAtomicCounter< T > Struct Template Reference

Inherits Base< T >.

Public Member Functions

void setAuxChk ()
 
void clearAuxChk ()
 
void auxLog (uint64_t step)
 
void doAuxLog (uint64_t step)
 
void auxCheck ()
 
T loadDirect ()
 
 AnnotatedAtomicCounter (int val)
 
void inc ()
 
void incBug ()
 

Detailed Description

template<typename T>
struct AnnotatedAtomicCounter< T >

Forward declaration of annotated template

Annotated shared class

Definition at line 170 of file DeterministicScheduleTest.cpp.

Constructor & Destructor Documentation

template<typename T >
AnnotatedAtomicCounter< T >::AnnotatedAtomicCounter ( int  val)
inlineexplicit

Definition at line 320 of file DeterministicScheduleTest.cpp.

320 : Base<T>(val) {}
double val
Definition: String.cpp:273

Member Function Documentation

template<typename T >
void AnnotatedAtomicCounter< T >::auxCheck ( )
inline

Definition at line 303 of file DeterministicScheduleTest.cpp.

References counter_, AuxData::lastUpdate_, AuxData::step_, sum(), folly::pushmi::detail::t, and AuxData::t_.

303  {
304  /* Liveness */
305  CHECK_LT(aux_->step_, aux_->lastUpdate_ + FLAGS_liveness_thresh);
306  /* Safety */
307  int sum = {0};
308  for (auto& t : aux_->t_) {
309  sum += t.count_;
310  }
311  CHECK_EQ(this->counter_.load_direct(), sum);
312  }
std::atomic< int64_t > sum(0)
static AuxData * aux_
folly::detail::CompressionCounter * counter_
std::vector< PerThread > t_
template<typename T >
void AnnotatedAtomicCounter< T >::auxLog ( uint64_t  step)
inline

Aux log function

Definition at line 273 of file DeterministicScheduleTest.cpp.

References AuxData::lastUpdate_, AuxData::step_, and uint64_t.

273  {
274  if (aux_->step_ == 0) {
275  aux_->lastUpdate_ = step;
276  }
277  aux_->step_ = step;
278  if (step > (uint64_t)FLAGS_max_steps) {
279  exit(0);
280  }
281  bool doLog =
282  (((FLAGS_log_begin > 0) && (step >= (uint64_t)FLAGS_log_begin) &&
283  (step <= (uint64_t)FLAGS_log_begin + FLAGS_log_length)) ||
284  ((step % FLAGS_log_freq) == 0));
285  if (doLog) {
286  doAuxLog(step);
287  }
288  }
static AuxData * aux_
template<typename T >
void AnnotatedAtomicCounter< T >::clearAuxChk ( )
inline

Definition at line 268 of file DeterministicScheduleTest.cpp.

References folly::test::DeterministicSchedule::clearAuxChk().

Referenced by TEST().

268  {
269  DeterministicSchedule::clearAuxChk();
270  }
template<typename T >
void AnnotatedAtomicCounter< T >::doAuxLog ( uint64_t  step)
inline

Definition at line 290 of file DeterministicScheduleTest.cpp.

References AUX_THR, counter_, AuxData::lastUpdate_, and tid_.

Referenced by TEST().

290  {
291  std::stringstream ss;
292  /* General */
293  ss << step << " - " << aux_->lastUpdate_ << " --";
294  /* Shared */
295  ss << " counter =" << this->counter_.load_direct();
296  /* Thread */
297  ss << " -- t" << tid_ << " " << AUX_THR(func_) << ":" << AUX_THR(line_);
298  ss << " count[" << tid_ << "] = " << AUX_THR(count_);
299  /* Output */
300  std::cerr << ss.str() << std::endl;
301  }
static AuxData * aux_
#define AUX_THR(x)
folly::detail::CompressionCounter * counter_
static FOLLY_TLS uint32_t tid_
template<typename T >
void AnnotatedAtomicCounter< T >::inc ( )
inline

Definition at line 324 of file DeterministicScheduleTest.cpp.

References AUX_ACT, AUX_THR, and counter_.

Referenced by TEST().

324  {
325  AUX_ACT({ ++AUX_THR(count_); });
326  this->counter_.fetch_add(1);
327  }
#define AUX_THR(x)
#define AUX_ACT(act)
folly::detail::CompressionCounter * counter_
template<typename T >
void AnnotatedAtomicCounter< T >::incBug ( )
inline

Definition at line 329 of file DeterministicScheduleTest.cpp.

References AUX_ACT, AUX_THR, counter_, and folly::T.

Referenced by TEST().

329  {
330  AUX_ACT({});
331  T newval = this->counter_.load() + 1;
332  AUX_ACT({ ++AUX_THR(count_); });
333  this->counter_.store(newval);
334  }
#define T(v)
Definition: http_parser.c:233
#define AUX_THR(x)
#define AUX_ACT(act)
folly::detail::CompressionCounter * counter_
template<typename T >
T AnnotatedAtomicCounter< T >::loadDirect ( )
inline

Definition at line 315 of file DeterministicScheduleTest.cpp.

References counter_.

Referenced by TEST().

315  {
316  return this->counter_.load_direct();
317  }
folly::detail::CompressionCounter * counter_
template<typename T >
void AnnotatedAtomicCounter< T >::setAuxChk ( )
inline

Manage DSched auxChk

Definition at line 260 of file DeterministicScheduleTest.cpp.

References folly::test::DeterministicSchedule::setAuxChk(), and uint64_t.

Referenced by TEST().

260  {
261  AuxChk auxfn([&](uint64_t step) {
262  auxLog(step);
263  auxCheck();
264  });
265  DeterministicSchedule::setAuxChk(auxfn);
266  }
std::function< void(uint64_t)> AuxChk

The documentation for this struct was generated from the following file: