Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
Pyston
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
Pyston
Commits
7853bcf2
Commit
7853bcf2
authored
Jun 17, 2014
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ok fine, a vector of std::atomic is not safe.
parent
18f9e7e0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
1 addition
and
11 deletions
+1
-11
src/core/stats.cpp
src/core/stats.cpp
+1
-5
src/core/stats.h
src/core/stats.h
+0
-6
No files found.
src/core/stats.cpp
View file @
7853bcf2
...
...
@@ -22,7 +22,6 @@ namespace pyston {
#if !DISABLE_STATS
std
::
vector
<
long
>*
Stats
::
counts
;
std
::
vector
<
std
::
atomic
<
long
>
>*
Stats
::
threadsafe_counts
;
std
::
unordered_map
<
int
,
std
::
string
>*
Stats
::
names
;
StatCounter
::
StatCounter
(
const
std
::
string
&
name
)
:
id
(
Stats
::
getStatId
(
name
))
{
}
...
...
@@ -39,8 +38,6 @@ int Stats::getStatId(const std::string& name) {
Stats
::
names
=
&
names
;
static
std
::
vector
<
long
>
counts
;
Stats
::
counts
=
&
counts
;
static
std
::
vector
<
std
::
atomic
<
long
>
>
threadsafe_counts
;
Stats
::
threadsafe_counts
=
&
threadsafe_counts
;
static
std
::
unordered_map
<
std
::
string
,
int
>
made
;
if
(
made
.
count
(
name
))
...
...
@@ -50,7 +47,6 @@ int Stats::getStatId(const std::string& name) {
names
[
rtn
]
=
name
;
made
[
name
]
=
rtn
;
counts
.
push_back
(
0
);
threadsafe_counts
.
emplace_back
(
0
);
return
rtn
;
}
...
...
@@ -65,7 +61,7 @@ void Stats::dump() {
std
::
sort
(
pairs
.
begin
(),
pairs
.
end
());
for
(
int
i
=
0
;
i
<
pairs
.
size
();
i
++
)
{
printf
(
"%s: %ld
\n
"
,
pairs
[
i
].
first
.
c_str
(),
(
*
counts
)[
pairs
[
i
].
second
]
+
(
*
threadsafe_counts
)[
pairs
[
i
].
second
]
);
printf
(
"%s: %ld
\n
"
,
pairs
[
i
].
first
.
c_str
(),
(
*
counts
)[
pairs
[
i
].
second
]);
}
}
...
...
src/core/stats.h
View file @
7853bcf2
...
...
@@ -31,16 +31,12 @@ namespace pyston {
struct
Stats
{
private:
static
std
::
vector
<
long
>*
counts
;
static
std
::
vector
<
std
::
atomic
<
long
>
>*
threadsafe_counts
;
static
std
::
unordered_map
<
int
,
std
::
string
>*
names
;
public:
static
int
getStatId
(
const
std
::
string
&
name
);
static
void
log
(
int
id
,
int
count
=
1
)
{
(
*
counts
)[
id
]
+=
count
;
}
static
void
threadsafe_log
(
int
id
,
int
count
=
1
)
{
(
*
threadsafe_counts
)[
id
].
fetch_add
(
count
,
std
::
memory_order_relaxed
);
}
static
void
dump
();
};
...
...
@@ -53,7 +49,6 @@ public:
StatCounter
(
const
std
::
string
&
name
);
void
log
(
int
count
=
1
)
{
Stats
::
log
(
id
,
count
);
}
void
threadsafe_log
(
int
count
=
1
)
{
Stats
::
threadsafe_log
(
id
,
count
);
}
};
struct
StatPerThreadCounter
{
...
...
@@ -64,7 +59,6 @@ public:
StatPerThreadCounter
(
const
std
::
string
&
name
);
void
log
(
int
count
=
1
)
{
Stats
::
log
(
id
,
count
);
}
void
threadsafe_log
(
int
count
=
1
)
{
Stats
::
threadsafe_log
(
id
,
count
);
}
};
#else
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment