Skip to content

Commit 8d3692a

Browse files
committed
Use atomics for thread safety
1 parent cec44c1 commit 8d3692a

File tree

2 files changed

+23
-16
lines changed

2 files changed

+23
-16
lines changed

src/Convex.jl

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,36 @@ export Positive, Negative, ComplexSign, NoSign
3434
# Problems
3535
export add_constraint!, add_constraints!, maximize, minimize, Problem, satisfy, solve!
3636

37+
38+
# Module level globals
39+
3740
"""
38-
const DCP_WARNINGS = Ref(true)
41+
DCP_WARNINGS
3942
4043
Controls whether or not warnings are emitted for when an expression fails to be
4144
of disciplined convex form. To turn warnings off, run
4245
4346
Convex.DCP_WARNINGS[] = false
4447
"""
45-
const DCP_WARNINGS = Ref(true)
48+
const DCP_WARNINGS = Threads.Atomic{Bool}(true)
49+
50+
"""
51+
MAXDEPTH
52+
53+
Controls depth of tree printing globally for Convex.jl; defaults to 3. Set via
54+
55+
Convex.MAXDEPTH[] = 5
56+
"""
57+
const MAXDEPTH = Threads.Atomic{Int}(3)
58+
59+
"""
60+
MAXWIDTH
61+
62+
Controls width of tree printing globally for Convex.jl; defaults to 15. Set via
63+
64+
Convex.MAXWIDTH[] = 15
65+
"""
66+
const MAXWIDTH= Threads.Atomic{Int}(15)
4667

4768
### modeling framework
4869
include("dcp.jl")

src/utilities/show.jl

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,6 @@
11
import Base.show, Base.summary
22
using .TreePrint
33

4-
"""
5-
const MAXDEPTH = Ref(3)
6-
7-
Controls depth of tree printing globally for Convex.jl
8-
"""
9-
const MAXDEPTH = Ref(3)
10-
11-
"""
12-
const MAXWIDTH = Ref(15)
13-
14-
Controls width of tree printing globally for Convex.jl
15-
"""
16-
const MAXWIDTH= Ref(15)
17-
184

195
"""
206
show_id(io::IO, x::Union{AbstractExpr, Constraint}; digits = 3)

0 commit comments

Comments
 (0)