6#define ADEBUG(...)     Ase::debug ("atomics", __VA_ARGS__) 
   23  for (
size_t i = 0; i < N; i++) {
 
   37  for (
size_t i = 0; i < a.size(); i++)
 
   43  for (
size_t i = 0; i < N; i++) {
 
   63atomic_next_ptrref (AisNode *node)
 
   70atomic_mpmcstack_test()
 
   79  was_empty = stack.
push (&n1);
 
   84  AisNode *node = stack.
pop_all();
 
   95static const size_t COUNTING_THREADS = N_THREADS + 1;
 
   96static constexpr const size_t NUMBER_NODES_PER_THREAD = 9999;
 
  102static ConcurrentNumberStack number_stack;
 
  103static NumberNode *allocated_number_nodes = 
nullptr;
 
  106run_count_number_nodes (NumberNode *nodes, ssize_t count)
 
  108  const pid_t tid = gettid();
 
  109  unsigned long long totals = 0, l = 0;
 
  111  while (i < count || j < count)
 
  113      for (
size_t t = 0; t < 77 && i < 
count; t++)
 
  115          NumberNode *node = nodes + i;
 
  117          number_stack.push (node);
 
  119      for (
size_t t = 0; t < 37 && j < 
count; t++)
 
  121          NumberNode *node = number_stack.pop();
 
  124              totals += node->number;
 
  126              if (r > 0 && (node->number & 0x1))
 
  130                  number_stack.push (node); 
 
  138            printout (
"thread %u: %llu\n", tid, totals);
 
  141  number_totals += totals;
 
  148  allocated_number_nodes = (NumberNode*) calloc (COUNTING_THREADS * NUMBER_NODES_PER_THREAD, 
sizeof (NumberNode));
 
  149  assert (allocated_number_nodes);
 
  152  for (
size_t i = 0; i < COUNTING_THREADS; i++)
 
  153    threads[i] = 
std::thread (run_count_number_nodes, allocated_number_nodes + i * NUMBER_NODES_PER_THREAD, NUMBER_NODES_PER_THREAD);
 
  154  for (
size_t i = 0; i < COUNTING_THREADS; i++)
 
  156  free (allocated_number_nodes);
 
  157  allocated_number_nodes = 
nullptr;
 
  158  assert (number_totals == COUNTING_THREADS * (NUMBER_NODES_PER_THREAD * (NUMBER_NODES_PER_THREAD + 1ull)) / 2);
 
  164atomic_valuestack_test()
 
  170  was_empty = sstack.
push (s);
 
  176  had = sstack.
pop (s);
 
  179  had = sstack.
pop (s);
 
  181  had = sstack.
pop (s);
 
Vector of atomic bits, operates in blocks of 64 bits.
 
bool push_chain(T *first, T *last)
Atomically push linked nodes first->…->last onto the stack, returns was_empty.
 
bool push(T *el)
Atomically push el onto the stack, returns was_empty.
 
bool empty() const
Check if poppingreturns null.
 
T hardware_concurrency(T... args)
 
#define TEST_INTEGRITY(FUNC)
Register func as an integrity test.
 
bool verbose()
Indicates whether tests should run verbosely.
 
The Anklang C++ API namespace.
 
boost::atomic< T > Atomic
Substitute for std::atomic<> with fixes for GCC.
 
bool empty() const
Return true if the stack holds no items.
 
bool pop(Value &value)
Pop value from top of the stack, returns if value was reassigned (true), otherwise the stack was empt...
 
bool push(Value &&value)
Add value to top of the stack, returns if the stack was empty (true).
 
#define TASSERT(cond)
Unconditional test assertion, enters breakpoint if not fullfilled.