proxygen
folly::test::DeterministicAtomicImpl< T, Schedule, Atom > Struct Template Reference

#include <DeterministicSchedule.h>

Public Member Functions

 DeterministicAtomicImpl ()=default
 
 ~DeterministicAtomicImpl ()=default
 
 DeterministicAtomicImpl (DeterministicAtomicImpl< T > const &)=delete
 
DeterministicAtomicImpl< T > & operator= (DeterministicAtomicImpl< T > const &)=delete
 
constexpr DeterministicAtomicImpl (T v) noexcept
 
bool is_lock_free () const noexcept
 
bool compare_exchange_strong (T &v0, T v1, std::memory_order mo=std::memory_order_seq_cst) noexcept
 
bool compare_exchange_strong (T &v0, T v1, std::memory_order success, std::memory_order failure) noexcept
 
bool compare_exchange_weak (T &v0, T v1, std::memory_order mo=std::memory_order_seq_cst) noexcept
 
bool compare_exchange_weak (T &v0, T v1, std::memory_order success, std::memory_order failure) noexcept
 
T exchange (T v, std::memory_order mo=std::memory_order_seq_cst) noexcept
 
 operator T () const noexcept
 
T load (std::memory_order mo=std::memory_order_seq_cst) const noexcept
 
T operator= (T v) noexcept
 
void store (T v, std::memory_order mo=std::memory_order_seq_cst) noexcept
 
T operator++ () noexcept
 
T operator++ (int) noexcept
 
T operator-- () noexcept
 
T operator-- (int) noexcept
 
T operator+= (T v) noexcept
 
T fetch_add (T v, std::memory_order mo=std::memory_order_seq_cst) noexcept
 
T operator-= (T v) noexcept
 
T fetch_sub (T v, std::memory_order mo=std::memory_order_seq_cst) noexcept
 
T operator&= (T v) noexcept
 
T fetch_and (T v, std::memory_order mo=std::memory_order_seq_cst) noexcept
 
T operator|= (T v) noexcept
 
T fetch_or (T v, std::memory_order mo=std::memory_order_seq_cst) noexcept
 
T operator^= (T v) noexcept
 
T fetch_xor (T v, std::memory_order mo=std::memory_order_seq_cst) noexcept
 
T load_direct () const noexcept
 

Private Attributes

Atom< Tdata_
 

Detailed Description

template<typename T, typename Schedule = DeterministicSchedule, template< typename > class Atom = std::atomic>
struct folly::test::DeterministicAtomicImpl< T, Schedule, Atom >

DeterministicAtomic<T> is a drop-in replacement std::atomic<T> that cooperates with DeterministicSchedule.

Definition at line 229 of file DeterministicSchedule.h.

Constructor & Destructor Documentation

template<typename T, typename Schedule = DeterministicSchedule, template< typename > class Atom = std::atomic>
folly::test::DeterministicAtomicImpl< T, Schedule, Atom >::DeterministicAtomicImpl ( )
default
template<typename T, typename Schedule = DeterministicSchedule, template< typename > class Atom = std::atomic>
folly::test::DeterministicAtomicImpl< T, Schedule, Atom >::~DeterministicAtomicImpl ( )
default
template<typename T, typename Schedule = DeterministicSchedule, template< typename > class Atom = std::atomic>
folly::test::DeterministicAtomicImpl< T, Schedule, Atom >::DeterministicAtomicImpl ( DeterministicAtomicImpl< T > const &  )
delete
template<typename T, typename Schedule = DeterministicSchedule, template< typename > class Atom = std::atomic>
constexpr folly::test::DeterministicAtomicImpl< T, Schedule, Atom >::DeterministicAtomicImpl ( T  v)
inlinenoexcept

Member Function Documentation

template<typename T, typename Schedule = DeterministicSchedule, template< typename > class Atom = std::atomic>
bool folly::test::DeterministicAtomicImpl< T, Schedule, Atom >::compare_exchange_strong ( T v0,
T  v1,
std::memory_order  mo = std::memory_order_seq_cst 
)
inlinenoexcept

Definition at line 242 of file DeterministicSchedule.h.

References folly::detail::default_failure_memory_order().

245  {
248  }
std::memory_order default_failure_memory_order(std::memory_order successMode)
Definition: AtomicUtils.h:24
bool compare_exchange_strong(T &v0, T v1, std::memory_order mo=std::memory_order_seq_cst) noexcept
template<typename T, typename Schedule = DeterministicSchedule, template< typename > class Atom = std::atomic>
bool folly::test::DeterministicAtomicImpl< T, Schedule, Atom >::compare_exchange_strong ( T v0,
T  v1,
std::memory_order  success,
std::memory_order  failure 
)
inlinenoexcept

Definition at line 249 of file DeterministicSchedule.h.

References data_, FOLLY_TEST_DSCHED_VLOG, and folly::detail::success.

253  {
254  Schedule::beforeSharedAccess();
255  auto orig = v0;
256  bool rv = data_.compare_exchange_strong(v0, v1, success, failure);
258  this << ".compare_exchange_strong(" << std::hex << orig << ", "
259  << std::hex << v1 << ") -> " << rv << "," << std::hex << v0);
260  Schedule::afterSharedAccess(rv);
261  return rv;
262  }
#define FOLLY_TEST_DSCHED_VLOG(...)
template<typename T, typename Schedule = DeterministicSchedule, template< typename > class Atom = std::atomic>
bool folly::test::DeterministicAtomicImpl< T, Schedule, Atom >::compare_exchange_weak ( T v0,
T  v1,
std::memory_order  mo = std::memory_order_seq_cst 
)
inlinenoexcept

Definition at line 264 of file DeterministicSchedule.h.

References folly::detail::default_failure_memory_order().

267  {
268  return compare_exchange_weak(
270  }
std::memory_order default_failure_memory_order(std::memory_order successMode)
Definition: AtomicUtils.h:24
bool compare_exchange_weak(T &v0, T v1, std::memory_order mo=std::memory_order_seq_cst) noexcept
template<typename T, typename Schedule = DeterministicSchedule, template< typename > class Atom = std::atomic>
bool folly::test::DeterministicAtomicImpl< T, Schedule, Atom >::compare_exchange_weak ( T v0,
T  v1,
std::memory_order  success,
std::memory_order  failure 
)
inlinenoexcept

Definition at line 271 of file DeterministicSchedule.h.

References data_, FOLLY_TEST_DSCHED_VLOG, and folly::detail::success.

275  {
276  Schedule::beforeSharedAccess();
277  auto orig = v0;
278  bool rv = data_.compare_exchange_weak(v0, v1, success, failure);
280  this << ".compare_exchange_weak(" << std::hex << orig << ", "
281  << std::hex << v1 << ") -> " << rv << "," << std::hex << v0);
282  Schedule::afterSharedAccess(rv);
283  return rv;
284  }
#define FOLLY_TEST_DSCHED_VLOG(...)
template<typename T, typename Schedule = DeterministicSchedule, template< typename > class Atom = std::atomic>
T folly::test::DeterministicAtomicImpl< T, Schedule, Atom >::exchange ( T  v,
std::memory_order  mo = std::memory_order_seq_cst 
)
inlinenoexcept

Definition at line 286 of file DeterministicSchedule.h.

References data_, FOLLY_TEST_DSCHED_VLOG, and folly::T.

286  {
287  Schedule::beforeSharedAccess();
288  T rv = data_.exchange(v, mo);
290  this << ".exchange(" << std::hex << v << ") -> " << std::hex << rv);
291  Schedule::afterSharedAccess(true);
292  return rv;
293  }
#define FOLLY_TEST_DSCHED_VLOG(...)
folly::std T
template<typename T, typename Schedule = DeterministicSchedule, template< typename > class Atom = std::atomic>
T folly::test::DeterministicAtomicImpl< T, Schedule, Atom >::fetch_add ( T  v,
std::memory_order  mo = std::memory_order_seq_cst 
)
inlinenoexcept

Definition at line 367 of file DeterministicSchedule.h.

References data_, FOLLY_TEST_DSCHED_VLOG, and folly::T.

367  {
368  Schedule::beforeSharedAccess();
369  T rv = data_.fetch_add(v, mo);
371  this << ".fetch_add(" << std::hex << v << ") -> " << std::hex << rv);
372  Schedule::afterSharedAccess(true);
373  return rv;
374  }
#define FOLLY_TEST_DSCHED_VLOG(...)
folly::std T
template<typename T, typename Schedule = DeterministicSchedule, template< typename > class Atom = std::atomic>
T folly::test::DeterministicAtomicImpl< T, Schedule, Atom >::fetch_and ( T  v,
std::memory_order  mo = std::memory_order_seq_cst 
)
inlinenoexcept

Definition at line 403 of file DeterministicSchedule.h.

References data_, FOLLY_TEST_DSCHED_VLOG, and folly::T.

403  {
404  Schedule::beforeSharedAccess();
405  T rv = data_.fetch_and(v, mo);
407  this << ".fetch_and(" << std::hex << v << ") -> " << std::hex << rv);
408  Schedule::afterSharedAccess(true);
409  return rv;
410  }
#define FOLLY_TEST_DSCHED_VLOG(...)
folly::std T
template<typename T, typename Schedule = DeterministicSchedule, template< typename > class Atom = std::atomic>
T folly::test::DeterministicAtomicImpl< T, Schedule, Atom >::fetch_or ( T  v,
std::memory_order  mo = std::memory_order_seq_cst 
)
inlinenoexcept

Definition at line 421 of file DeterministicSchedule.h.

References data_, FOLLY_TEST_DSCHED_VLOG, and folly::T.

421  {
422  Schedule::beforeSharedAccess();
423  T rv = data_.fetch_or(v, mo);
425  this << ".fetch_or(" << std::hex << v << ") -> " << std::hex << rv);
426  Schedule::afterSharedAccess(true);
427  return rv;
428  }
#define FOLLY_TEST_DSCHED_VLOG(...)
folly::std T
template<typename T, typename Schedule = DeterministicSchedule, template< typename > class Atom = std::atomic>
T folly::test::DeterministicAtomicImpl< T, Schedule, Atom >::fetch_sub ( T  v,
std::memory_order  mo = std::memory_order_seq_cst 
)
inlinenoexcept

Definition at line 385 of file DeterministicSchedule.h.

References data_, FOLLY_TEST_DSCHED_VLOG, and folly::T.

385  {
386  Schedule::beforeSharedAccess();
387  T rv = data_.fetch_sub(v, mo);
389  this << ".fetch_sub(" << std::hex << v << ") -> " << std::hex << rv);
390  Schedule::afterSharedAccess(true);
391  return rv;
392  }
#define FOLLY_TEST_DSCHED_VLOG(...)
folly::std T
template<typename T, typename Schedule = DeterministicSchedule, template< typename > class Atom = std::atomic>
T folly::test::DeterministicAtomicImpl< T, Schedule, Atom >::fetch_xor ( T  v,
std::memory_order  mo = std::memory_order_seq_cst 
)
inlinenoexcept

Definition at line 439 of file DeterministicSchedule.h.

References data_, FOLLY_TEST_DSCHED_VLOG, and folly::T.

439  {
440  Schedule::beforeSharedAccess();
441  T rv = data_.fetch_xor(v, mo);
443  this << ".fetch_xor(" << std::hex << v << ") -> " << std::hex << rv);
444  Schedule::afterSharedAccess(true);
445  return rv;
446  }
#define FOLLY_TEST_DSCHED_VLOG(...)
folly::std T
template<typename T, typename Schedule = DeterministicSchedule, template< typename > class Atom = std::atomic>
bool folly::test::DeterministicAtomicImpl< T, Schedule, Atom >::is_lock_free ( ) const
inlinenoexcept

Definition at line 238 of file DeterministicSchedule.h.

References data_.

238  {
239  return data_.is_lock_free();
240  }
template<typename T, typename Schedule = DeterministicSchedule, template< typename > class Atom = std::atomic>
T folly::test::DeterministicAtomicImpl< T, Schedule, Atom >::load ( std::memory_order  mo = std::memory_order_seq_cst) const
inlinenoexcept

Definition at line 303 of file DeterministicSchedule.h.

References data_, FOLLY_TEST_DSCHED_VLOG, and folly::T.

Referenced by TEST_F().

303  {
304  Schedule::beforeSharedAccess();
305  T rv = data_.load(mo);
306  FOLLY_TEST_DSCHED_VLOG(this << ".load() -> " << std::hex << rv);
307  Schedule::afterSharedAccess(true);
308  return rv;
309  }
#define FOLLY_TEST_DSCHED_VLOG(...)
folly::std T
template<typename T, typename Schedule = DeterministicSchedule, template< typename > class Atom = std::atomic>
T folly::test::DeterministicAtomicImpl< T, Schedule, Atom >::load_direct ( ) const
inlinenoexcept

Read the value of the atomic variable without context switching

Definition at line 449 of file DeterministicSchedule.h.

References data_.

449  {
450  return data_.load(std::memory_order_relaxed);
451  }
template<typename T, typename Schedule = DeterministicSchedule, template< typename > class Atom = std::atomic>
folly::test::DeterministicAtomicImpl< T, Schedule, Atom >::operator T ( ) const
inlinenoexcept

Definition at line 295 of file DeterministicSchedule.h.

References data_, FOLLY_TEST_DSCHED_VLOG, and folly::T.

295  {
296  Schedule::beforeSharedAccess();
297  T rv = data_.operator T();
298  FOLLY_TEST_DSCHED_VLOG(this << "() -> " << std::hex << rv);
299  Schedule::afterSharedAccess(true);
300  return rv;
301  }
#define FOLLY_TEST_DSCHED_VLOG(...)
folly::std T
template<typename T, typename Schedule = DeterministicSchedule, template< typename > class Atom = std::atomic>
T folly::test::DeterministicAtomicImpl< T, Schedule, Atom >::operator&= ( T  v)
inlinenoexcept

Definition at line 394 of file DeterministicSchedule.h.

References data_, FOLLY_TEST_DSCHED_VLOG, folly::T, and v.

394  {
395  Schedule::beforeSharedAccess();
396  T rv = (data_ &= v);
398  this << " &= " << std::hex << v << " -> " << std::hex << rv);
399  Schedule::afterSharedAccess(true);
400  return rv;
401  }
auto v
#define FOLLY_TEST_DSCHED_VLOG(...)
folly::std T
template<typename T, typename Schedule = DeterministicSchedule, template< typename > class Atom = std::atomic>
T folly::test::DeterministicAtomicImpl< T, Schedule, Atom >::operator++ ( )
inlinenoexcept

Definition at line 326 of file DeterministicSchedule.h.

References data_, FOLLY_TEST_DSCHED_VLOG, and folly::T.

326  {
327  Schedule::beforeSharedAccess();
328  T rv = ++data_;
329  FOLLY_TEST_DSCHED_VLOG(this << " pre++ -> " << std::hex << rv);
330  Schedule::afterSharedAccess(true);
331  return rv;
332  }
#define FOLLY_TEST_DSCHED_VLOG(...)
folly::std T
template<typename T, typename Schedule = DeterministicSchedule, template< typename > class Atom = std::atomic>
T folly::test::DeterministicAtomicImpl< T, Schedule, Atom >::operator++ ( int  )
inlinenoexcept

Definition at line 334 of file DeterministicSchedule.h.

References data_, FOLLY_TEST_DSCHED_VLOG, and folly::T.

334  {
335  Schedule::beforeSharedAccess();
336  T rv = data_++;
337  FOLLY_TEST_DSCHED_VLOG(this << " post++ -> " << std::hex << rv);
338  Schedule::afterSharedAccess(true);
339  return rv;
340  }
#define FOLLY_TEST_DSCHED_VLOG(...)
folly::std T
template<typename T, typename Schedule = DeterministicSchedule, template< typename > class Atom = std::atomic>
T folly::test::DeterministicAtomicImpl< T, Schedule, Atom >::operator+= ( T  v)
inlinenoexcept

Definition at line 358 of file DeterministicSchedule.h.

References data_, FOLLY_TEST_DSCHED_VLOG, folly::T, and v.

358  {
359  Schedule::beforeSharedAccess();
360  T rv = (data_ += v);
362  this << " += " << std::hex << v << " -> " << std::hex << rv);
363  Schedule::afterSharedAccess(true);
364  return rv;
365  }
auto v
#define FOLLY_TEST_DSCHED_VLOG(...)
folly::std T
template<typename T, typename Schedule = DeterministicSchedule, template< typename > class Atom = std::atomic>
T folly::test::DeterministicAtomicImpl< T, Schedule, Atom >::operator-- ( )
inlinenoexcept

Definition at line 342 of file DeterministicSchedule.h.

References data_, FOLLY_TEST_DSCHED_VLOG, and folly::T.

342  {
343  Schedule::beforeSharedAccess();
344  T rv = --data_;
345  FOLLY_TEST_DSCHED_VLOG(this << " pre-- -> " << std::hex << rv);
346  Schedule::afterSharedAccess(true);
347  return rv;
348  }
#define FOLLY_TEST_DSCHED_VLOG(...)
folly::std T
template<typename T, typename Schedule = DeterministicSchedule, template< typename > class Atom = std::atomic>
T folly::test::DeterministicAtomicImpl< T, Schedule, Atom >::operator-- ( int  )
inlinenoexcept

Definition at line 350 of file DeterministicSchedule.h.

References data_, FOLLY_TEST_DSCHED_VLOG, and folly::T.

350  {
351  Schedule::beforeSharedAccess();
352  T rv = data_--;
353  FOLLY_TEST_DSCHED_VLOG(this << " post-- -> " << std::hex << rv);
354  Schedule::afterSharedAccess(true);
355  return rv;
356  }
#define FOLLY_TEST_DSCHED_VLOG(...)
folly::std T
template<typename T, typename Schedule = DeterministicSchedule, template< typename > class Atom = std::atomic>
T folly::test::DeterministicAtomicImpl< T, Schedule, Atom >::operator-= ( T  v)
inlinenoexcept

Definition at line 376 of file DeterministicSchedule.h.

References data_, FOLLY_TEST_DSCHED_VLOG, folly::T, and v.

376  {
377  Schedule::beforeSharedAccess();
378  T rv = (data_ -= v);
380  this << " -= " << std::hex << v << " -> " << std::hex << rv);
381  Schedule::afterSharedAccess(true);
382  return rv;
383  }
auto v
#define FOLLY_TEST_DSCHED_VLOG(...)
folly::std T
template<typename T, typename Schedule = DeterministicSchedule, template< typename > class Atom = std::atomic>
DeterministicAtomicImpl<T>& folly::test::DeterministicAtomicImpl< T, Schedule, Atom >::operator= ( DeterministicAtomicImpl< T > const &  )
delete
template<typename T, typename Schedule = DeterministicSchedule, template< typename > class Atom = std::atomic>
T folly::test::DeterministicAtomicImpl< T, Schedule, Atom >::operator= ( T  v)
inlinenoexcept

Definition at line 311 of file DeterministicSchedule.h.

References data_, FOLLY_TEST_DSCHED_VLOG, folly::T, and v.

311  {
312  Schedule::beforeSharedAccess();
313  T rv = (data_ = v);
314  FOLLY_TEST_DSCHED_VLOG(this << " = " << std::hex << v);
315  Schedule::afterSharedAccess(true);
316  return rv;
317  }
auto v
#define FOLLY_TEST_DSCHED_VLOG(...)
folly::std T
template<typename T, typename Schedule = DeterministicSchedule, template< typename > class Atom = std::atomic>
T folly::test::DeterministicAtomicImpl< T, Schedule, Atom >::operator^= ( T  v)
inlinenoexcept

Definition at line 430 of file DeterministicSchedule.h.

References data_, FOLLY_TEST_DSCHED_VLOG, folly::T, and v.

430  {
431  Schedule::beforeSharedAccess();
432  T rv = (data_ ^= v);
434  this << " ^= " << std::hex << v << " -> " << std::hex << rv);
435  Schedule::afterSharedAccess(true);
436  return rv;
437  }
auto v
#define FOLLY_TEST_DSCHED_VLOG(...)
folly::std T
template<typename T, typename Schedule = DeterministicSchedule, template< typename > class Atom = std::atomic>
T folly::test::DeterministicAtomicImpl< T, Schedule, Atom >::operator|= ( T  v)
inlinenoexcept

Definition at line 412 of file DeterministicSchedule.h.

References data_, FOLLY_TEST_DSCHED_VLOG, folly::T, and v.

412  {
413  Schedule::beforeSharedAccess();
414  T rv = (data_ |= v);
416  this << " |= " << std::hex << v << " -> " << std::hex << rv);
417  Schedule::afterSharedAccess(true);
418  return rv;
419  }
auto v
#define FOLLY_TEST_DSCHED_VLOG(...)
folly::std T
template<typename T, typename Schedule = DeterministicSchedule, template< typename > class Atom = std::atomic>
void folly::test::DeterministicAtomicImpl< T, Schedule, Atom >::store ( T  v,
std::memory_order  mo = std::memory_order_seq_cst 
)
inlinenoexcept

Definition at line 319 of file DeterministicSchedule.h.

References data_, and FOLLY_TEST_DSCHED_VLOG.

Referenced by TEST_F().

319  {
320  Schedule::beforeSharedAccess();
321  data_.store(v, mo);
322  FOLLY_TEST_DSCHED_VLOG(this << ".store(" << std::hex << v << ")");
323  Schedule::afterSharedAccess(true);
324  }
#define FOLLY_TEST_DSCHED_VLOG(...)

Member Data Documentation

template<typename T, typename Schedule = DeterministicSchedule, template< typename > class Atom = std::atomic>
Atom<T> folly::test::DeterministicAtomicImpl< T, Schedule, Atom >::data_
private

Definition at line 454 of file DeterministicSchedule.h.


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