Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jlib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
captainwong
jlib
Commits
d3dbb70d
Commit
d3dbb70d
authored
5 years ago
by
captainwong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
testing atomic
parent
9a769384
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
3 deletions
+3
-3
test_atomic.cpp
test/test_atomic/test_atomic.cpp
+3
-3
No files found.
test/test_atomic/test_atomic.cpp
View file @
d3dbb70d
...
@@ -9,7 +9,7 @@ void test()
...
@@ -9,7 +9,7 @@ void test()
using
namespace
std
;
using
namespace
std
;
using
namespace
std
::
chrono
;
using
namespace
std
::
chrono
;
uint
32
_t
count
=
0
;
uint
max
_t
count
=
0
;
while
(
true
)
{
while
(
true
)
{
atomic_int
x
(
0
),
y
(
0
);
atomic_int
x
(
0
),
y
(
0
);
int
r1
=
0
,
r2
=
0
;
int
r1
=
0
,
r2
=
0
;
...
@@ -30,14 +30,14 @@ void test()
...
@@ -30,14 +30,14 @@ void test()
t2
.
join
();
t2
.
join
();
count
++
;
count
++
;
printf
(
"
\r
%zd
"
,
count
);
printf
(
"
%lld
\r
"
,
count
);
if
(
r1
==
42
&&
r2
==
42
)
{
if
(
r1
==
42
&&
r2
==
42
)
{
printf
(
"
\n
"
);
printf
(
"
\n
"
);
break
;
break
;
}
}
}
}
printf
(
"after %d times trying, r1,r2 are finally 42!
\n
"
,
count
);
printf
(
"after %
ll
d times trying, r1,r2 are finally 42!
\n
"
,
count
);
}
}
int
main
()
int
main
()
...
...
This diff is collapsed.
Click to expand it.
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