Skip to content

Commit 8464338

Browse files
committed
Merge pull request #5692 from maxGimeno/CGAL_cpp11_atomic_and_threads-maxGimeno
CGAL:: Use std atomic and threads
2 parents 35929d1 + 17ac255 commit 8464338

File tree

27 files changed

+159
-125
lines changed

27 files changed

+159
-125
lines changed

Apollonius_graph_2/include/CGAL/Apollonius_graph_2/comparator_profiler.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020

2121
#include <CGAL/Apollonius_graph_2/basic.h>
22-
#include <CGAL/atomic.h>
22+
#include <atomic>
2323

2424
namespace CGAL {
2525

@@ -33,8 +33,8 @@ class comparator_profiler
3333
typedef bool bool_;
3434
typedef unsigned long long_;
3535
#else
36-
typedef CGAL::cpp11::atomic<bool> bool_;
37-
typedef CGAL::cpp11::atomic<unsigned long> long_;
36+
typedef std::atomic<bool> bool_;
37+
typedef std::atomic<unsigned long> long_;
3838
#endif
3939

4040
static bool_ count_cases;

Apollonius_graph_2/include/CGAL/Apollonius_graph_2/predicate_profiler.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020

2121
#include <CGAL/Apollonius_graph_2/basic.h>
22-
#include <CGAL/atomic.h>
22+
#include <atomic>
2323

2424
#define AG2_PROFILE_PREDICATES
2525

@@ -33,7 +33,7 @@ class ag2_predicate_profiler
3333
#ifdef CGAL_NO_ATOMIC
3434
typedef unsigned long long_;
3535
#else
36-
typedef CGAL::cpp11::atomic<unsigned long> long_;
36+
typedef std::atomic<unsigned long> long_;
3737
#endif
3838

3939
// high level predicates

Arrangement_on_surface_2/include/CGAL/Arr_circle_segment_traits_2.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@
2323
* The header file for the Arr_circle_segment_traits_2<Kenrel> class.
2424
*/
2525

26-
#include <CGAL/atomic.h>
2726
#include <CGAL/tags.h>
2827
#include <CGAL/Arr_tags.h>
2928
#include <CGAL/Arr_geometry_traits/Circle_segment_2.h>
3029

3130
#include <fstream>
31+
#include <atomic>
3232

3333
namespace CGAL {
3434

@@ -80,7 +80,7 @@ class Arr_circle_segment_traits_2 {
8080
#ifdef CGAL_NO_ATOMIC
8181
static unsigned int index;
8282
#else
83-
static CGAL::cpp11::atomic<unsigned int> index;
83+
static std::atomic<unsigned int> index;
8484
#endif
8585
return (++index);
8686
}

Arrangement_on_surface_2/include/CGAL/Arr_conic_traits_2.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
*/
2424

2525
#include <fstream>
26+
#include <atomic>
2627

27-
#include <CGAL/atomic.h>
2828
#include <CGAL/tags.h>
2929
#include <CGAL/Arr_tags.h>
3030
#include <CGAL/Arr_geometry_traits/Conic_arc_2.h>
@@ -108,7 +108,7 @@ class Arr_conic_traits_2
108108
#ifdef CGAL_NO_ATOMIC
109109
static unsigned int index;
110110
#else
111-
static CGAL::cpp11::atomic<unsigned int> index;
111+
static std::atomic<unsigned int> index;
112112
#endif
113113
return (++index);
114114
}

Arrangement_on_surface_2/include/CGAL/Arr_counting_traits_2.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626

2727
#include <iostream>
2828
#include <string.h>
29+
#include <atomic>
2930

3031
#include <CGAL/basic.h>
31-
#include <CGAL/atomic.h>
3232
#include <CGAL/Arr_enums.h>
3333
#include <CGAL/Arr_tags.h>
3434

@@ -950,7 +950,7 @@ class Arr_counting_traits_2 : public Base_traits {
950950
#ifdef CGAL_NO_ATOMIC
951951
static unsigned int counter;
952952
#else
953-
static CGAL::cpp11::atomic<unsigned int> counter;
953+
static std::atomic<size_t> counter;
954954
#endif
955955
if (doit) ++counter;
956956
return counter;

Box_intersection_d/include/CGAL/Box_intersection_d/Box_d.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
#include <CGAL/Bbox_2.h>
2222
#include <CGAL/Bbox_3.h>
2323
#include <CGAL/Box_intersection_d/box_limits.h>
24-
#include <CGAL/atomic.h>
2524

2625
#include <algorithm>
2726
#include <array>
27+
#include <atomic>
2828

2929
namespace CGAL {
3030

@@ -38,7 +38,7 @@ struct Unique_numbers {
3838
#ifdef CGAL_NO_ATOMIC
3939
static std::size_t n = 0;
4040
#else
41-
static CGAL::cpp11::atomic<std::size_t> n; // initialized to 0
41+
static std::atomic<std::size_t> n; // initialized to 0
4242
#endif
4343
i = n++;
4444
}

CGAL_Core/include/CGAL/CORE/CoreDefs.h

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@
2929
#define _CORE_COREDEFS_H_
3030

3131
#include <CGAL/CORE/extLong.h>
32-
#include <CGAL/atomic.h>
3332
#include <CGAL/disable_warnings.h>
3433

34+
#include <atomic>
35+
3536
#ifdef CGAL_HEADER_ONLY
3637

3738
#define CGAL_GLOBAL_STATE_VAR(TYPE, NAME, VALUE) \
@@ -75,7 +76,7 @@ namespace CORE {
7576
#ifdef CGAL_NO_ATOMIC
7677
CGAL_GLOBAL_STATE_VAR(bool, AbortFlag, true)
7778
#else
78-
CGAL_GLOBAL_STATE_VAR(CGAL::cpp11::atomic<bool>, AbortFlag, true)
79+
CGAL_GLOBAL_STATE_VAR(std::atomic<bool>, AbortFlag, true)
7980
#endif
8081

8182
/// Invalid Flag -- initiallly value is non-negative
@@ -86,7 +87,7 @@ CGAL_GLOBAL_STATE_VAR(CGAL::cpp11::atomic<bool>, AbortFlag, true)
8687
#ifdef CGAL_NO_ATOMIC
8788
CGAL_GLOBAL_STATE_VAR(int, InvalidFlag, 0)
8889
#else
89-
CGAL_GLOBAL_STATE_VAR(CGAL::cpp11::atomic<int>, InvalidFlag, 0)
90+
CGAL_GLOBAL_STATE_VAR(std::atomic<int>, InvalidFlag, 0)
9091
#endif
9192

9293
/// Escape Precision in bits
@@ -102,7 +103,7 @@ CGAL_GLOBAL_STATE_VAR(long, EscapePrecFlag, 0)
102103
#ifdef CGAL_NO_ATOMIC
103104
CGAL_GLOBAL_STATE_VAR(bool, EscapePrecWarning, true)
104105
#else
105-
CGAL_GLOBAL_STATE_VAR(CGAL::cpp11::atomic<bool>, EscapePrecWarning, true)
106+
CGAL_GLOBAL_STATE_VAR(std::atomic<bool>, EscapePrecWarning, true)
106107
#endif
107108

108109
// These following two values determine the precision of computing
@@ -124,7 +125,7 @@ CGAL_GLOBAL_STATE_VAR(extLong, defAbsPrec, CORE_posInfty)
124125
#ifdef CGAL_NO_ATOMIC
125126
CGAL_GLOBAL_STATE_VAR(long, defBigFloatOutputDigits, 10)
126127
#else
127-
CGAL_GLOBAL_STATE_VAR(CGAL::cpp11::atomic<long>, defBigFloatOutputDigits, 10)
128+
CGAL_GLOBAL_STATE_VAR(std::atomic<long>, defBigFloatOutputDigits, 10)
128129
#endif
129130

130131
/// default input precision in digits for converting a string to a Real or Expr
@@ -138,15 +139,15 @@ CGAL_GLOBAL_STATE_VAR(extLong, defInputDigits, CORE_posInfty)
138139
#ifdef CGAL_NO_ATOMIC
139140
CGAL_GLOBAL_STATE_VAR(long, defOutputDigits, 10) // == get_static_defBigFloatOutputDigits()
140141
#else
141-
CGAL_GLOBAL_STATE_VAR(CGAL::cpp11::atomic<long>, defOutputDigits, 10) // == get_static_defBigFloatOutputDigits()
142+
CGAL_GLOBAL_STATE_VAR(std::atomic<long>, defOutputDigits, 10) // == get_static_defBigFloatOutputDigits()
142143
#endif
143144

144145
/// default input precision in digits for converting a string to a BigFloat
145146
/** This value cannot be CORE_INFTY. */
146147
#ifdef CGAL_NO_ATOMIC
147148
CGAL_GLOBAL_STATE_VAR(long, defBigFloatInputDigits, 16)
148149
#else
149-
CGAL_GLOBAL_STATE_VAR(CGAL::cpp11::atomic<long>, defBigFloatInputDigits, 16)
150+
CGAL_GLOBAL_STATE_VAR(std::atomic<long>, defBigFloatInputDigits, 16)
150151
#endif
151152

152153
inline
@@ -169,38 +170,38 @@ CGAL_GLOBAL_STATE_VAR(extLong, defBFsqrtAbsPrec, 54)
169170
#ifdef CGAL_NO_ATOMIC
170171
CGAL_GLOBAL_STATE_VAR(bool, fpFilterFlag, true)
171172
#else
172-
CGAL_GLOBAL_STATE_VAR(CGAL::cpp11::atomic<bool>, fpFilterFlag, true)
173+
CGAL_GLOBAL_STATE_VAR(std::atomic<bool>, fpFilterFlag, true)
173174
#endif
174175

175176

176177
/// if true, evaluation of expressions would be incremental
177178
#ifdef CGAL_NO_ATOMIC
178179
CGAL_GLOBAL_STATE_VAR(bool, incrementalEvalFlag, true)
179180
#else
180-
CGAL_GLOBAL_STATE_VAR(CGAL::cpp11::atomic<bool>, incrementalEvalFlag, true)
181+
CGAL_GLOBAL_STATE_VAR(std::atomic<bool>, incrementalEvalFlag, true)
181182
#endif
182183

183184

184185
/// progressive evaluation flag
185186
#ifdef CGAL_NO_ATOMIC
186187
CGAL_GLOBAL_STATE_VAR(bool, progressiveEvalFlag, true)
187188
#else
188-
CGAL_GLOBAL_STATE_VAR(CGAL::cpp11::atomic<bool>, progressiveEvalFlag, true)
189+
CGAL_GLOBAL_STATE_VAR(std::atomic<bool>, progressiveEvalFlag, true)
189190
#endif
190191

191192

192193
/// rational reduction flag
193194
#ifdef CGAL_NO_ATOMIC
194195
CGAL_GLOBAL_STATE_VAR(bool, rationalReduceFlag, false)
195196
#else
196-
CGAL_GLOBAL_STATE_VAR(CGAL::cpp11::atomic<bool>, rationalReduceFlag, false)
197+
CGAL_GLOBAL_STATE_VAR(std::atomic<bool>, rationalReduceFlag, false)
197198
#endif
198199

199200
/// default initial (bit) precision for AddSub Progressive Evaluation
200201
#ifdef CGAL_NO_ATOMIC
201202
CGAL_GLOBAL_STATE_VAR(long, defInitialProgressivePrec, 64)
202203
#else
203-
CGAL_GLOBAL_STATE_VAR(CGAL::cpp11::atomic<long>, defInitialProgressivePrec, 64)
204+
CGAL_GLOBAL_STATE_VAR(std::atomic<long>, defInitialProgressivePrec, 64)
204205
#endif
205206

206207
//////////////////////////////////////////////////////////////

CGAL_Core/include/CGAL/CORE/CoreDefs_impl.h

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424

2525
#include "CGAL/CORE/CoreDefs.h"
2626

27+
#include <atomic>
28+
2729
namespace CORE {
2830

2931
// Default Values
@@ -50,7 +52,7 @@ int IOErrorFlag = 0;
5052
#ifdef CGAL_NO_ATOMIC
5153
bool AbortFlag = true;
5254
#else
53-
CGAL::cpp11::atomic<bool> AbortFlag(true);
55+
std::atomic<bool> AbortFlag(true);
5456
#endif
5557

5658
/**
@@ -61,7 +63,7 @@ CGAL::cpp11::atomic<bool> AbortFlag(true);
6163
#ifdef CGAL_NO_ATOMIC
6264
int InvalidFlag = 0;
6365
#else
64-
CGAL::cpp11::atomic<int> InvalidFlag(0);
66+
std::atomic<int> InvalidFlag(0);
6567
#endif
6668

6769
/* ************************************************************
@@ -97,7 +99,7 @@ long EscapePrecFlag = 0;
9799
#ifdef CGAL_NO_ATOMIC
98100
bool EscapePrecWarning = true;
99101
#else
100-
CGAL::cpp11::atomic<bool> EscapePrecWarning(true);
102+
std::atomic<bool> EscapePrecWarning(true);
101103
#endif
102104

103105
/** The Composite Precision [defAbsPrec, defRelPrec]
@@ -117,15 +119,15 @@ extLong defRelPrec = 60;
117119
#ifdef CGAL_NO_ATOMIC
118120
long defBigFloatOutputDigits = 10;
119121
#else
120-
CGAL::cpp11::atomic<long> defBigFloatOutputDigits(10);
122+
std::atomic<long> defBigFloatOutputDigits(10);
121123
#endif
122124

123125
/** NORMALLY, we like to make this equal to defBigFloatOutputDigits
124126
* 8/3/01, Chee: re-introduced this parameter */
125127
#ifdef CGAL_NO_ATOMIC
126128
long defOutputDigits = 10;
127129
#else
128-
CGAL::cpp11::atomic<long> defOutputDigits(10); // == defBigFloatOutputDigits;
130+
std::atomic<long> defOutputDigits(10); // == defBigFloatOutputDigits;
129131
#endif
130132

131133
/** String Input Precision */
@@ -142,7 +144,7 @@ extLong defInputDigits = CORE_posInfty;
142144
#ifdef CGAL_NO_ATOMIC
143145
long defBigFloatInputDigits = 16;
144146
#else
145-
CGAL::cpp11::atomic<long> defBigFloatInputDigits(16);
147+
std::atomic<long> defBigFloatInputDigits(16);
146148
#endif
147149

148150
/* ************************************************************
@@ -154,7 +156,7 @@ CGAL::cpp11::atomic<long> defBigFloatInputDigits(16);
154156
#ifdef CGAL_NO_ATOMIC
155157
bool fpFilterFlag = true;
156158
#else
157-
CGAL::cpp11::atomic<bool> fpFilterFlag(true);
159+
std::atomic<bool> fpFilterFlag(true);
158160
#endif
159161

160162
/** IncrementaL evaluation flag
@@ -163,31 +165,31 @@ CGAL::cpp11::atomic<bool> fpFilterFlag(true);
163165
#ifdef CGAL_NO_ATOMIC
164166
bool incrementalEvalFlag = true;
165167
#else
166-
CGAL::cpp11::atomic<bool> incrementalEvalFlag(true);
168+
std::atomic<bool> incrementalEvalFlag(true);
167169
#endif
168170

169171
/** Progressive evaluation flag
170172
* true = turn on progressive evaluation flag */
171173
#ifdef CGAL_NO_ATOMIC
172174
bool progressiveEvalFlag = true;
173175
#else
174-
CGAL::cpp11::atomic<bool> progressiveEvalFlag(true);
176+
std::atomic<bool> progressiveEvalFlag(true);
175177
#endif
176178

177179
/** Initial progressive evaluation precision
178180
* Used by AddSubRep */
179181
#ifdef CGAL_NO_ATOMIC
180182
long defInitialProgressivePrec = 64;
181183
#else
182-
CGAL::cpp11::atomic<long> defInitialProgressivePrec(64);
184+
std::atomic<long> defInitialProgressivePrec(64);
183185
#endif
184186

185187
/** RATIONAL REDUCTION FLAG
186188
* true = turn on rational reduction */
187189
#ifdef CGAL_NO_ATOMIC
188190
bool rationalReduceFlag = false;
189191
#else
190-
CGAL::cpp11::atomic<bool> rationalReduceFlag(false);
192+
std::atomic<bool> rationalReduceFlag(false);
191193
#endif
192194
#endif // CGAL_HEADER_ONLY
193195

Installation/include/CGAL/atomic.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
#ifndef CGAL_ATOMIC_H
1111
#define CGAL_ATOMIC_H
1212

13+
#define CGAL_DEPRECATED_HEADER "<CGAL/atomic.h>"
14+
#define CGAL_REPLACEMENT_HEADER "<CGAL/config.h>"
15+
1316
#include <CGAL/config.h>
1417

1518
#ifdef CGAL_HAS_THREADS

Installation/include/CGAL/config.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,9 @@ using std::max;
645645
# include <unordered_set>
646646
# include <unordered_map>
647647
# include <functional>
648+
# include <thread>
649+
# include <chrono>
650+
# include <atomic>
648651
//
649652
namespace CGAL {
650653
//
@@ -663,6 +666,16 @@ namespace CGAL {
663666
using std::is_enum;
664667
using std::unordered_set;
665668
using std::unordered_map;
669+
using std::atomic;
670+
using std::memory_order_relaxed;
671+
using std::memory_order_consume;
672+
using std::memory_order_acquire;
673+
using std::memory_order_release;
674+
using std::memory_order_acq_rel;
675+
using std::memory_order_seq_cst;
676+
using std::atomic_thread_fence;
677+
using std::thread;
678+
666679
}
667680
//
668681
namespace cpp0x = cpp11;

0 commit comments

Comments
 (0)