NexusForce 1.0.0
A rigorously engineered full-stack C++ backend library.
载入中...
搜索中...
未找到
atomic.hpp
浏览该文件的文档.
1#ifndef NEFORCE_CORE_ASYNC_ATOMIC_HPP__
2#define NEFORCE_CORE_ASYNC_ATOMIC_HPP__
3
10
12NEFORCE_BEGIN_NAMESPACE__
13
19
25
33template <typename T>
34struct atomic {
35 using value_type = T;
36
37private:
38 static constexpr int min_align = (sizeof(T) & (sizeof(T) - 1)) != 0U || sizeof(T) > 16 ? 0 : sizeof(T);
39 static constexpr int align_inner = min_align > alignof(T) ? min_align : alignof(T);
40
41 alignas(align_inner) T value_;
42
43 static_assert(is_trivially_copyable_v<T>, "atomic requires a trivially copyable type");
44 static_assert(is_complete_v<T>, "Incomplete or zero-sized types are not supported");
45 static_assert(is_copy_constructible_v<T>, "atomic need copy constructible T");
46 static_assert(is_move_constructible_v<T>, "atomic need move constructible T");
47 static_assert(is_copy_assignable_v<T>, "atomic copy move assignable T");
48 static_assert(is_move_assignable_v<T>, "atomic need move assignable T");
49
50public:
51 atomic() = default;
52 ~atomic() noexcept = default;
53 atomic(const atomic&) = delete;
54 atomic& operator=(const atomic&) = delete;
55 atomic& operator=(const atomic&) volatile = delete;
56 atomic(atomic&&) noexcept = default;
57 atomic& operator=(atomic&&) noexcept = default;
58
63 constexpr atomic(T value) noexcept :
64 value_(value) {}
65
70 operator T() const noexcept { return load(); }
71
75 operator T() const volatile noexcept { return load(); }
76
82 T operator=(T value) noexcept {
83 atomic::store(value);
84 return value;
85 }
86
90 T operator=(T value) volatile noexcept {
91 atomic::store(value);
92 return value;
93 }
94
99 NEFORCE_NODISCARD bool is_lock_free() const noexcept {
101 }
102
106 NEFORCE_NODISCARD bool is_lock_free() const volatile noexcept {
108 }
109
115 void store(T value, const memory_order mo = memory_order_seq_cst) noexcept {
116 _NEFORCE atomic_store_any(_NEFORCE addressof(value_), value, mo);
117 }
118
122 void store(T value, const memory_order mo = memory_order_seq_cst) volatile noexcept {
123 _NEFORCE atomic_store_any(_NEFORCE addressof(value_), value, mo);
124 }
125
131 T load(const memory_order mo = memory_order_seq_cst) const noexcept {
132 return _NEFORCE atomic_load_any(_NEFORCE addressof(value_), mo);
133 }
134
138 T load(const memory_order mo = memory_order_seq_cst) const volatile noexcept {
139 return _NEFORCE atomic_load_any(_NEFORCE addressof(value_), mo);
140 }
141
148 T exchange(T value, const memory_order mo = memory_order_seq_cst) noexcept {
149 return _NEFORCE atomic_exchange_any(_NEFORCE addressof(value_), value, mo);
150 }
151
155 T exchange(T value, const memory_order mo = memory_order_seq_cst) volatile noexcept {
156 return _NEFORCE atomic_exchange_any(_NEFORCE addressof(value_), value, mo);
157 }
158
167 bool compare_exchange_weak(T& expected, T desired, const memory_order success,
168 const memory_order failure) noexcept {
170 return _NEFORCE atomic_cmpexch_weak_any(_NEFORCE addressof(value_), &expected, &desired, success, failure);
171 }
172
176 bool compare_exchange_weak(T& expected, T desired, const memory_order success,
177 const memory_order failure) volatile noexcept {
179 return _NEFORCE atomic_cmpexch_weak_any(_NEFORCE addressof(value_), &expected, &desired, success, failure);
180 }
181
189 bool compare_exchange_weak(T& expected, T desired, const memory_order mo = memory_order_seq_cst) noexcept {
190 return atomic::compare_exchange_weak(expected, desired, mo, cmpexch_failure_order(mo));
191 }
192
196 bool compare_exchange_weak(T& expected, T desired, const memory_order mo = memory_order_seq_cst) volatile noexcept {
197 return atomic::compare_exchange_weak(expected, desired, mo, cmpexch_failure_order(mo));
198 }
199
208 bool compare_exchange_strong(T& expected, T desired, const memory_order success,
209 const memory_order failure) noexcept {
211 return _NEFORCE atomic_cmpexch_strong_any(_NEFORCE addressof(value_), _NEFORCE addressof(expected),
212 _NEFORCE addressof(desired), success, failure);
213 }
214
218 bool compare_exchange_strong(T& expected, T desired, const memory_order success,
219 const memory_order failure) volatile noexcept {
221 return _NEFORCE atomic_cmpexch_strong_any(_NEFORCE addressof(value_), _NEFORCE addressof(expected),
222 _NEFORCE addressof(desired), success, failure);
223 }
224
232 bool compare_exchange_strong(T& expected, T value, const memory_order mo = memory_order_seq_cst) noexcept {
233 return atomic::compare_exchange_strong(expected, value, mo, cmpexch_failure_order(mo));
234 }
235
239 bool compare_exchange_strong(T& expected, T value, const memory_order mo = memory_order_seq_cst) volatile noexcept {
240 return atomic::compare_exchange_strong(expected, value, mo, cmpexch_failure_order(mo));
241 }
242};
243
248template <typename T>
249struct atomic<T*> : atomic_base<T*> {
250 atomic() noexcept = default;
251 ~atomic() noexcept = default;
252 atomic(const atomic&) = delete;
253 atomic& operator=(const atomic&) = delete;
254 atomic& operator=(const atomic&) volatile = delete;
255 atomic(atomic&&) noexcept = default;
256 atomic& operator=(atomic&&) noexcept = default;
257
258 explicit atomic(T* value) noexcept :
259 atomic_base<T*>(value) {}
260
261 using atomic_base<T*>::operator=;
262};
263
268template <typename T>
269struct atomic<T&> : atomic_ref_base<T> {
270 atomic() = default;
271 ~atomic() noexcept = default;
272 atomic(const atomic&) = delete;
273 atomic& operator=(const atomic&) = delete;
274 atomic& operator=(const atomic&) volatile = delete;
275 atomic(atomic&&) noexcept = default;
276 atomic& operator=(atomic&&) noexcept = default;
277
278 explicit atomic(T& value) noexcept :
279 atomic_ref_base<T>(value) {}
280
281 using atomic_ref_base<T>::operator=;
282};
283
284
289template <>
290struct atomic<bool> {
291 using value_type = bool;
292
293private:
294 atomic_base<bool> base_;
295
296public:
297 atomic() = default;
298 ~atomic() noexcept = default;
299 atomic(const atomic&) = delete;
300 atomic& operator=(const atomic&) = delete;
301 atomic& operator=(const atomic&) volatile = delete;
302 atomic(atomic&&) noexcept = default;
303 atomic& operator=(atomic&&) noexcept = default;
304
309 constexpr atomic(const bool value) noexcept :
310 base_(value) {}
311
317 bool operator=(const bool value) noexcept { return base_.operator=(value); }
318
322 bool operator=(const bool value) volatile noexcept { return base_.operator=(value); }
323
328 operator bool() const noexcept { return base_.load(); }
329
333 operator bool() const volatile noexcept { return base_.load(); }
334
339 NEFORCE_NODISCARD bool is_lock_free() const noexcept { return base_.is_lock_free(); }
340
344 NEFORCE_NODISCARD bool is_lock_free() const volatile noexcept { return base_.is_lock_free(); }
345
351 void store(const bool value, const memory_order mo = memory_order_seq_cst) noexcept { base_.store(value, mo); }
352
356 void store(const bool value, const memory_order mo = memory_order_seq_cst) volatile noexcept {
357 base_.store(value, mo);
358 }
359
365 NEFORCE_NODISCARD bool load(const memory_order mo = memory_order_seq_cst) const noexcept { return base_.load(mo); }
366
370 NEFORCE_NODISCARD bool load(const memory_order mo = memory_order_seq_cst) const volatile noexcept {
371 return base_.load(mo);
372 }
373
380 bool exchange(const bool value, const memory_order mo = memory_order_seq_cst) noexcept {
381 return base_.exchange(value, mo);
382 }
383
387 bool exchange(const bool value, const memory_order mo = memory_order_seq_cst) volatile noexcept {
388 return base_.exchange(value, mo);
389 }
390
399 bool compare_exchange_weak(bool& value1, const bool value2, const memory_order success,
400 const memory_order failure) noexcept {
401 return base_.compare_exchange_weak(value1, value2, success, failure);
402 }
403
407 bool compare_exchange_weak(bool& value1, const bool value2, const memory_order success,
408 const memory_order failure) volatile noexcept {
409 return base_.compare_exchange_weak(value1, value2, success, failure);
410 }
411
419 bool compare_exchange_weak(bool& value1, const bool value2, const memory_order mo = memory_order_seq_cst) noexcept {
420 return base_.compare_exchange_weak(value1, value2, mo);
421 }
422
426 bool compare_exchange_weak(bool& value1, const bool value2,
427 const memory_order mo = memory_order_seq_cst) volatile noexcept {
428 return base_.compare_exchange_weak(value1, value2, mo);
429 }
430
439 bool compare_exchange_strong(bool& value1, const bool value2, const memory_order success,
440 const memory_order failure) noexcept {
441 return base_.compare_exchange_strong(value1, value2, success, failure);
442 }
443
447 bool compare_exchange_strong(bool& value1, const bool value2, const memory_order success,
448 const memory_order failure) volatile noexcept {
449 return base_.compare_exchange_strong(value1, value2, success, failure);
450 }
451
459 bool compare_exchange_strong(bool& value1, const bool value2,
460 const memory_order mo = memory_order_seq_cst) noexcept {
461 return base_.compare_exchange_strong(value1, value2, mo);
462 }
463
467 bool compare_exchange_strong(bool& value1, const bool value2,
468 const memory_order mo = memory_order_seq_cst) volatile noexcept {
469 return base_.compare_exchange_strong(value1, value2, mo);
470 }
471
477 void wait(const bool old, const memory_order mo = memory_order_seq_cst) const noexcept { base_.wait(old, mo); }
478
482 void notify_one() noexcept { base_.notify_one(); }
483
487 void notify_all() noexcept { base_.notify_all(); }
488};
489
491template <>
492struct atomic<char> : atomic_base<char> {
493 using integral_type = char;
494 using base_type = atomic_base<char>;
495
496 atomic() = default;
497 ~atomic() noexcept = default;
498 atomic(const atomic&) = delete;
499 atomic& operator=(const atomic&) = delete;
500 atomic& operator=(const atomic&) volatile = delete;
501 atomic(atomic&&) noexcept = default;
502 atomic& operator=(atomic&&) noexcept = default;
503
504 constexpr atomic(const integral_type value) noexcept :
505 base_type(value) {}
506
507 using base_type::operator integral_type;
508 using base_type::operator=;
509
510 static constexpr bool is_always_lock_free = true;
511};
512
514template <>
515struct atomic<signed char> : atomic_base<signed char> {
516 using integral_type = signed char;
517 using base_type = atomic_base<signed char>;
518
519 atomic() = default;
520 ~atomic() noexcept = default;
521 atomic(const atomic&) = delete;
522 atomic& operator=(const atomic&) = delete;
523 atomic& operator=(const atomic&) volatile = delete;
524 atomic(atomic&&) noexcept = default;
525 atomic& operator=(atomic&&) noexcept = default;
526
527 constexpr atomic(const integral_type value) noexcept :
528 base_type(value) {}
529
530 using base_type::operator integral_type;
531 using base_type::operator=;
532
533 static constexpr bool is_always_lock_free = true;
534};
535
537template <>
538struct atomic<unsigned char> : atomic_base<unsigned char> {
539 using integral_type = unsigned char;
540 using base_type = atomic_base<unsigned char>;
541
542 atomic() = default;
543 ~atomic() noexcept = default;
544 atomic(const atomic&) = delete;
545 atomic& operator=(const atomic&) = delete;
546 atomic& operator=(const atomic&) volatile = delete;
547 atomic(atomic&&) noexcept = default;
548 atomic& operator=(atomic&&) noexcept = default;
549
550 constexpr atomic(const integral_type value) noexcept :
551 base_type(value) {}
552
553 using base_type::operator integral_type;
554 using base_type::operator=;
555
556 static constexpr bool is_always_lock_free = true;
557};
558
560template <>
561struct atomic<short> : atomic_base<short> {
562 using integral_type = short;
563 using base_type = atomic_base<short>;
564
565 atomic() = default;
566 ~atomic() noexcept = default;
567 atomic(const atomic&) = delete;
568 atomic& operator=(const atomic&) = delete;
569 atomic& operator=(const atomic&) volatile = delete;
570 atomic(atomic&&) noexcept = default;
571 atomic& operator=(atomic&&) noexcept = default;
572
573 constexpr atomic(const integral_type value) noexcept :
574 base_type(value) {}
575
576 using base_type::operator integral_type;
577 using base_type::operator=;
578
579 static constexpr bool is_always_lock_free = true;
580};
581
583template <>
584struct atomic<unsigned short> : atomic_base<unsigned short> {
585 using integral_type = unsigned short;
586 using base_type = atomic_base<unsigned short>;
587
588 atomic() = default;
589 ~atomic() noexcept = default;
590 atomic(const atomic&) = delete;
591 atomic& operator=(const atomic&) = delete;
592 atomic& operator=(const atomic&) volatile = delete;
593 atomic(atomic&&) noexcept = default;
594 atomic& operator=(atomic&&) noexcept = default;
595
596 constexpr atomic(const integral_type value) noexcept :
597 base_type(value) {}
598
599 using base_type::operator integral_type;
600 using base_type::operator=;
601
602 static constexpr bool is_always_lock_free = true;
603};
604
606template <>
607struct atomic<int> : atomic_base<int> {
608 using integral_type = int;
609 using base_type = atomic_base<int>;
610
611 atomic() = default;
612 ~atomic() noexcept = default;
613 atomic(const atomic&) = delete;
614 atomic& operator=(const atomic&) = delete;
615 atomic& operator=(const atomic&) volatile = delete;
616 atomic(atomic&&) noexcept = default;
617 atomic& operator=(atomic&&) noexcept = default;
618
619 constexpr atomic(const integral_type value) noexcept :
620 base_type(value) {}
621
622 using base_type::operator integral_type;
623 using base_type::operator=;
624
625 static constexpr bool is_always_lock_free = true;
626};
627
629template <>
630struct atomic<unsigned int> : atomic_base<unsigned int> {
631 using integral_type = unsigned int;
632 using base_type = atomic_base<unsigned int>;
633
634 atomic() = default;
635 ~atomic() noexcept = default;
636 atomic(const atomic&) = delete;
637 atomic& operator=(const atomic&) = delete;
638 atomic& operator=(const atomic&) volatile = delete;
639 atomic(atomic&&) noexcept = default;
640 atomic& operator=(atomic&&) noexcept = default;
641
642 constexpr atomic(const integral_type value) noexcept :
643 base_type(value) {}
644
645 using base_type::operator integral_type;
646 using base_type::operator=;
647
648 static constexpr bool is_always_lock_free = true;
649};
650
652template <>
653struct atomic<long> : atomic_base<long> {
654 using integral_type = long;
655 using base_type = atomic_base<long>;
656
657 atomic() = default;
658 ~atomic() noexcept = default;
659 atomic(const atomic&) = delete;
660 atomic& operator=(const atomic&) = delete;
661 atomic& operator=(const atomic&) volatile = delete;
662 atomic(atomic&&) noexcept = default;
663 atomic& operator=(atomic&&) noexcept = default;
664
665 constexpr atomic(const integral_type value) noexcept :
666 base_type(value) {}
667
668 using base_type::operator integral_type;
669 using base_type::operator=;
670
671 static constexpr bool is_always_lock_free = true;
672};
673
675template <>
676struct atomic<unsigned long> : atomic_base<unsigned long> {
677 using integral_type = unsigned long;
678 using base_type = atomic_base<unsigned long>;
679
680 atomic() = default;
681 ~atomic() noexcept = default;
682 atomic(const atomic&) = delete;
683 atomic& operator=(const atomic&) = delete;
684 atomic& operator=(const atomic&) volatile = delete;
685 atomic(atomic&&) noexcept = default;
686 atomic& operator=(atomic&&) noexcept = default;
687
688 constexpr atomic(const integral_type value) noexcept :
689 base_type(value) {}
690
691 using base_type::operator integral_type;
692 using base_type::operator=;
693
694 static constexpr bool is_always_lock_free = true;
695};
696
698template <>
699struct atomic<long long> : atomic_base<long long> {
700 using integral_type = long long;
701 using base_type = atomic_base<long long>;
702
703 atomic() = default;
704 ~atomic() noexcept = default;
705 atomic(const atomic&) = delete;
706 atomic& operator=(const atomic&) = delete;
707 atomic& operator=(const atomic&) volatile = delete;
708 atomic(atomic&&) noexcept = default;
709 atomic& operator=(atomic&&) noexcept = default;
710
711 constexpr atomic(const integral_type value) noexcept :
712 base_type(value) {}
713
714 using base_type::operator integral_type;
715 using base_type::operator=;
716
717 static constexpr bool is_always_lock_free = true;
718};
719
721template <>
722struct atomic<unsigned long long> : atomic_base<unsigned long long> {
723 using integral_type = unsigned long long;
724 using base_type = atomic_base<unsigned long long>;
725
726 atomic() = default;
727 ~atomic() noexcept = default;
728 atomic(const atomic&) = delete;
729 atomic& operator=(const atomic&) = delete;
730 atomic& operator=(const atomic&) volatile = delete;
731 atomic(atomic&&) noexcept = default;
732 atomic& operator=(atomic&&) noexcept = default;
733
734 constexpr atomic(const integral_type value) noexcept :
735 base_type(value) {}
736
737 using base_type::operator integral_type;
738 using base_type::operator=;
739
740 static constexpr bool is_always_lock_free = true;
741};
742
744template <>
745struct atomic<wchar_t> : atomic_base<wchar_t> {
746 using integral_type = wchar_t;
747 using base_type = atomic_base<wchar_t>;
748
749 atomic() = default;
750 ~atomic() noexcept = default;
751 atomic(const atomic&) = delete;
752 atomic& operator=(const atomic&) = delete;
753 atomic& operator=(const atomic&) volatile = delete;
754 atomic(atomic&&) noexcept = default;
755 atomic& operator=(atomic&&) noexcept = default;
756
757 constexpr atomic(const integral_type value) noexcept :
758 base_type(value) {}
759
760 using base_type::operator integral_type;
761 using base_type::operator=;
762
763 static constexpr bool is_always_lock_free = true;
764};
765
766#ifdef NEFORCE_STANDARD_20
768template <>
769struct atomic<char8_t> : atomic_base<char8_t> {
770 using integral_type = char8_t;
771 using base_type = atomic_base<char8_t>;
772
773 atomic() = default;
774 ~atomic() noexcept = default;
775 atomic(const atomic&) = delete;
776 atomic& operator=(const atomic&) = delete;
777 atomic& operator=(const atomic&) volatile = delete;
778 atomic(atomic&&) noexcept = default;
779 atomic& operator=(atomic&&) noexcept = default;
780
781 constexpr atomic(const integral_type value) noexcept :
782 base_type(value) {}
783
784 using base_type::operator integral_type;
785 using base_type::operator=;
786
787 static constexpr bool is_always_lock_free = true;
788};
789#endif
790
792template <>
793struct atomic<char16_t> : atomic_base<char16_t> {
794 using integral_type = char16_t;
795 using base_type = atomic_base<char16_t>;
796
797 atomic() = default;
798 ~atomic() noexcept = default;
799 atomic(const atomic&) = delete;
800 atomic& operator=(const atomic&) = delete;
801 atomic& operator=(const atomic&) volatile = delete;
802 atomic(atomic&&) noexcept = default;
803 atomic& operator=(atomic&&) noexcept = default;
804
805 constexpr atomic(const integral_type value) noexcept :
806 base_type(value) {}
807
808 using base_type::operator integral_type;
809 using base_type::operator=;
810
811 static constexpr bool is_always_lock_free = true;
812};
813
815template <>
816struct atomic<char32_t> : atomic_base<char32_t> {
817 using integral_type = char32_t;
818 using base_type = atomic_base<char32_t>;
819
820 atomic() = default;
821 ~atomic() noexcept = default;
822 atomic(const atomic&) = delete;
823 atomic& operator=(const atomic&) = delete;
824 atomic& operator=(const atomic&) volatile = delete;
825 atomic(atomic&&) noexcept = default;
826 atomic& operator=(atomic&&) noexcept = default;
827
828 constexpr atomic(const integral_type value) noexcept :
829 base_type(value) {}
830
831 using base_type::operator integral_type;
832 using base_type::operator=;
833
834 static constexpr bool is_always_lock_free = true;
835};
836
838template <>
839struct atomic<float> : atomic_float_base<float> {
840 atomic() = default;
841 ~atomic() noexcept = default;
842 atomic(const atomic&) = delete;
843 atomic& operator=(const atomic&) = delete;
844 atomic& operator=(const atomic&) volatile = delete;
845 atomic(atomic&&) noexcept = default;
846 atomic& operator=(atomic&&) noexcept = default;
847
848 constexpr atomic(const float value) noexcept :
849 atomic_float_base<float>(value) {}
850
851 using atomic_float_base<float>::operator=;
852};
853
855template <>
856struct atomic<double> : atomic_float_base<double> {
857 atomic() = default;
858 ~atomic() noexcept = default;
859 atomic(const atomic&) = delete;
860 atomic& operator=(const atomic&) = delete;
861 atomic& operator=(const atomic&) volatile = delete;
862 atomic(atomic&&) noexcept = default;
863 atomic& operator=(atomic&&) noexcept = default;
864
865 constexpr atomic(const double value) noexcept :
866 atomic_float_base<double>(value) {}
867
868 using atomic_float_base<double>::operator=;
869};
870
872template <>
873struct atomic<long double> : atomic_float_base<long double> {
874 atomic() = default;
875 ~atomic() noexcept = default;
876 atomic(const atomic&) = delete;
877 atomic& operator=(const atomic&) = delete;
878 atomic& operator=(const atomic&) volatile = delete;
879 atomic(atomic&&) noexcept = default;
880 atomic& operator=(atomic&&) noexcept = default;
881
882 constexpr atomic(const long double value) noexcept :
883 atomic_float_base<long double>(value) {}
884
885 using atomic_float_base<long double>::operator=;
886};
887 // AtomicOperations
889 // AsyncComponents
891
892NEFORCE_END_NAMESPACE__
893#endif // NEFORCE_CORE_ASYNC_ATOMIC_HPP__
原子操作基本工具
constexpr T * addressof(T &x) noexcept
获取对象的地址
remove_volatile_t< T > atomic_load_any(const T *ptr, memory_order mo) noexcept
通用原子加载操作
bool atomic_cmpexch_weak_any(volatile T *ptr, remove_volatile_t< T > *expected, remove_volatile_t< T > *desired, const memory_order success, const memory_order failure) noexcept
通用弱比较交换操作
constexpr bool is_always_lock_free() noexcept
检查是否支持无锁操作
bool atomic_cmpexch_strong_any(volatile T *ptr, remove_volatile_t< T > *expected, remove_volatile_t< T > *desired, const memory_order success, const memory_order failure) noexcept
通用强比较交换操作
void atomic_store_any(T *ptr, remove_volatile_t< T > value, const memory_order mo) noexcept
通用原子存储操作
remove_volatile_t< T > atomic_exchange_any(T *ptr, remove_volatile_t< T > desired, memory_order mo) noexcept
通用原子交换操作
#define NEFORCE_CONSTEXPR_ASSERT(COND)
编译时常量断言
constexpr auto memory_order_seq_cst
顺序一致性内存顺序常量
constexpr memory_order cmpexch_failure_order(const memory_order mo) noexcept
获取原子比较交换操作失败时的内存顺序
memory_order
内存顺序
constexpr bool is_valid_cmpexch_failure_order(const memory_order mo) noexcept
检查比较交换失败内存顺序是否有效
constexpr bool is_move_constructible_v
is_move_constructible的便捷变量模板
constexpr bool is_move_assignable_v
is_move_assignable的便捷变量模板
constexpr bool is_copy_assignable_v
is_copy_assignable的便捷变量模板
constexpr bool is_trivially_copyable_v
is_trivially_copyable的便捷变量模板
constexpr bool is_copy_constructible_v
is_copy_constructible的便捷变量模板
void store(const bool value, const memory_order mo=memory_order_seq_cst) noexcept
原子存储操作
bool compare_exchange_weak(bool &value1, const bool value2, const memory_order mo=memory_order_seq_cst) noexcept
简化版弱比较交换操作
bool operator=(const bool value) noexcept
赋值运算符
bool load(const memory_order mo=memory_order_seq_cst) const noexcept
原子加载操作
bool exchange(const bool value, const memory_order mo=memory_order_seq_cst) volatile noexcept
volatile版本的原子交换操作
void store(const bool value, const memory_order mo=memory_order_seq_cst) volatile noexcept
volatile版本的原子存储操作
bool compare_exchange_strong(bool &value1, const bool value2, const memory_order mo=memory_order_seq_cst) noexcept
简化版强比较交换操作
bool compare_exchange_strong(bool &value1, const bool value2, const memory_order mo=memory_order_seq_cst) volatile noexcept
volatile版本的简化版强比较交换操作
bool load(const memory_order mo=memory_order_seq_cst) const volatile noexcept
volatile版本的原子加载操作
bool compare_exchange_weak(bool &value1, const bool value2, const memory_order mo=memory_order_seq_cst) volatile noexcept
volatile版本的简化版弱比较交换操作
bool is_lock_free() const noexcept
检查是否支持无锁操作
void notify_one() noexcept
通知一个等待线程
bool exchange(const bool value, const memory_order mo=memory_order_seq_cst) noexcept
原子交换操作
bool compare_exchange_weak(bool &value1, const bool value2, const memory_order success, const memory_order failure) volatile noexcept
volatile版本的弱比较交换操作
bool operator=(const bool value) volatile noexcept
volatile版本的赋值运算符
void wait(const bool old, const memory_order mo=memory_order_seq_cst) const noexcept
等待值改变
void notify_all() noexcept
通知所有等待线程
bool compare_exchange_strong(bool &value1, const bool value2, const memory_order success, const memory_order failure) noexcept
强比较交换操作
bool compare_exchange_weak(bool &value1, const bool value2, const memory_order success, const memory_order failure) noexcept
弱比较交换操作
bool is_lock_free() const volatile noexcept
volatile版本的检查是否支持无锁操作
bool compare_exchange_strong(bool &value1, const bool value2, const memory_order success, const memory_order failure) volatile noexcept
volatile版本的强比较交换操作
原子类型基础模板类
原子引用基础模板类
T load(const memory_order mo=memory_order_seq_cst) const volatile noexcept
volatile版本的原子加载操作
bool compare_exchange_weak(T &expected, T desired, const memory_order mo=memory_order_seq_cst) noexcept
简化版弱比较交换操作
T operator=(T value) volatile noexcept
volatile版本的赋值运算符
bool compare_exchange_strong(T &expected, T value, const memory_order mo=memory_order_seq_cst) noexcept
简化版强比较交换操作
block * load(const memory_order mo=memory_order_seq_cst) const noexcept
bool compare_exchange_weak(T &expected, T desired, const memory_order mo=memory_order_seq_cst) volatile noexcept
volatile版本的简化版弱比较交换操作
void store(T value, const memory_order mo=memory_order_seq_cst) volatile noexcept
volatile版本的原子存储操作
T operator=(T value) noexcept
赋值运算符
T exchange(T value, const memory_order mo=memory_order_seq_cst) volatile noexcept
volatile版本的原子交换操作
T value_type
值类型
bool compare_exchange_strong(T &expected, T desired, const memory_order success, const memory_order failure) noexcept
强比较交换操作
bool is_lock_free() const volatile noexcept
volatile版本的检查是否支持无锁操作
T exchange(T value, const memory_order mo=memory_order_seq_cst) noexcept
原子交换操作
bool compare_exchange_weak(T &expected, T desired, const memory_order success, const memory_order failure) noexcept
弱比较交换操作
bool compare_exchange_weak(T &expected, T desired, const memory_order success, const memory_order failure) volatile noexcept
volatile版本的弱比较交换操作
bool compare_exchange_strong(T &expected, T value, const memory_order mo=memory_order_seq_cst) volatile noexcept
volatile版本的简化版强比较交换操作
void store(T value, const memory_order mo=memory_order_seq_cst) noexcept
原子存储操作
bool is_lock_free() const noexcept
检查是否支持无锁操作
bool compare_exchange_strong(T &expected, T desired, const memory_order success, const memory_order failure) volatile noexcept
volatile版本的强比较交换操作