Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
S
spdlog
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
spdlog
Commits
0bf2391d
Commit
0bf2391d
authored
Jan 27, 2014
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix test
parent
3a30e57d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
10 deletions
+20
-10
makefile
build/gcc/makefile
+3
-3
test.cpp
src/test.cpp
+17
-7
No files found.
build/gcc/makefile
View file @
0bf2391d
...
...
@@ -7,9 +7,9 @@ OBJS_DEBUG = $(patsubst %.cpp,debug/%.o,$(_SOURCES))
CXX
=
g++
CXXFLAGS
=
-Wall
-std
=
c++11
-pthread
-I
../../include
CXX_RELEASE_FLAGS
=
-O
3
-flto
CXX_DEBUG_FLAGS
=
-g
CXXFLAGS
=
-
march
=
native
-
Wall
-std
=
c++11
-pthread
-I
../../include
CXX_RELEASE_FLAGS
=
-O
2
-flto
CXX_DEBUG_FLAGS
=
-g
-ggdb
OUTLIB_RELEASE
=
libc11log.a
OUTLIB_DEBUG
=
libc11log-debug.a
...
...
src/test.cpp
View file @
0bf2391d
...
...
@@ -26,27 +26,37 @@ int main(int argc, char* argv[])
logger
.
add_sink
(
async
);
std
::
atomic
<
uint32_t
>
counter
{
0
};
auto
counter_ptr
=
&
counter
;
std
::
cout
<<
"Starting "
<<
nthreads
<<
" threads.."
<<
std
::
endl
;
auto
counter_ptr
=
&
counter
;
std
::
atomic
<
bool
>
active
{
true
};
auto
active_ptr
=
&
active
;
std
::
vector
<
std
::
thread
*>
threads
;
std
::
cout
<<
"Starting "
<<
nthreads
<<
" threads for 3 seconds.."
<<
std
::
endl
;
for
(
int
i
=
0
;
i
<
nthreads
;
i
++
)
{
new
std
::
thread
([
&
logger
,
counter
_ptr
]()
{
while
(
true
)
auto
t
=
new
std
::
thread
([
&
logger
,
counter_ptr
,
active
_ptr
]()
{
while
(
*
active_ptr
)
{
logger
.
info
()
<<
"Hello from thread "
<<
std
::
this_thread
::
get_id
()
<<
"
\t
counter: "
<<
counter_ptr
->
load
();
(
*
counter_ptr
)
++
;
}
}
});
threads
.
push_back
(
t
);
}
int
seconds
=
0
;
while
(
seconds
++
<
5
)
while
(
seconds
++
<
3
)
{
counter
=
0
;
std
::
this_thread
::
sleep_for
(
std
::
chrono
::
seconds
(
1
));
std
::
cout
<<
"Counter = "
<<
utils
::
format
(
counter
.
load
())
<<
std
::
endl
;
}
async
->
shutdown
(
std
::
chrono
::
seconds
(
10
));
active
=
false
;
for
(
auto
t
:
threads
)
t
->
join
();
async
->
shutdown
(
std
::
chrono
::
seconds
(
1
));
return
0
;
}
...
...
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