Eigen::Barrier Class Reference

#include <Barrier.h>

+ Inheritance diagram for Eigen::Barrier:

Public Member Functions

 Barrier (unsigned int count)
 
 ~Barrier ()
 
void Notify ()
 
void Wait ()
 

Private Attributes

EIGEN_MUTEX mu_
 
EIGEN_CONDVAR cv_
 
std::atomic< unsigned intstate_
 
bool notified_
 

Constructor & Destructor Documentation

◆ Barrier()

Eigen::Barrier::Barrier ( unsigned int  count)
inline
23  : state_(count << 1), notified_(false) {
24  eigen_plain_assert(((count << 1) >> 1) == count);
25  }
#define eigen_plain_assert(condition)
Definition: Assert.h:148
bool notified_
Definition: Barrier.h:56
std::atomic< unsigned int > state_
Definition: Barrier.h:55

References eigen_plain_assert.

◆ ~Barrier()

Eigen::Barrier::~Barrier ( )
inline
26 { eigen_plain_assert((state_ >> 1) == 0); }

References eigen_plain_assert, and state_.

Member Function Documentation

◆ Notify()

void Eigen::Barrier::Notify ( )
inline
28  {
29  unsigned int v = state_.fetch_sub(2, std::memory_order_acq_rel) - 2;
30  if (v != 1) {
31  // Clear the lowest bit (waiter flag) and check that the original state
32  // value was not zero. If it was zero, it means that notify was called
33  // more times than the original count.
34  eigen_plain_assert(((v + 2) & ~1) != 0);
35  return; // either count has not dropped to 0, or waiter is not waiting
36  }
37  EIGEN_MUTEX_LOCK l(mu_);
39  notified_ = true;
40  cv_.notify_all();
41  }
Array< int, Dynamic, 1 > v
Definition: Array_initializer_list_vector_cxx11.cpp:1
EIGEN_CONDVAR cv_
Definition: Barrier.h:54
EIGEN_MUTEX mu_
Definition: Barrier.h:53

References cv_, eigen_plain_assert, mu_, notified_, state_, and v.

Referenced by Eigen::ForkJoinScheduler::ParallelFor(), Eigen::CoreThreadPoolDevice::parallelForImpl(), test_async_execute_binary_expr(), test_async_execute_unary_expr(), test_async_multithread_contraction_agrees_with_singlethread(), test_async_parallel_for(), test_large_number_of_tasks_no_spill(), test_large_number_of_tasks_with_spill(), and test_simple_thread_local().

◆ Wait()

void Eigen::Barrier::Wait ( )
inline

Member Data Documentation

◆ cv_

EIGEN_CONDVAR Eigen::Barrier::cv_
private

Referenced by Notify(), and Wait().

◆ mu_

EIGEN_MUTEX Eigen::Barrier::mu_
private

Referenced by Notify(), and Wait().

◆ notified_

bool Eigen::Barrier::notified_
private

Referenced by Notify(), and Wait().

◆ state_

std::atomic<unsigned int> Eigen::Barrier::state_
private

Referenced by Notify(), Wait(), and ~Barrier().


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