Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dlib
Commits
f4f39597
Commit
f4f39597
authored
Sep 27, 2014
by
Davis King
Browse files
Added scope qualifiers to some mutex objects to avoid a name collision
in newer versions of clang.
parent
ae9701bc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
3 deletions
+3
-3
examples/parallel_for_ex.cpp
examples/parallel_for_ex.cpp
+2
-2
examples/threads_ex.cpp
examples/threads_ex.cpp
+1
-1
No files found.
examples/parallel_for_ex.cpp
View file @
f4f39597
...
@@ -148,7 +148,7 @@ void example_using_lambda_functions()
...
@@ -148,7 +148,7 @@ void example_using_lambda_functions()
// parallel for loop is implemented using threads, all the usual techniques for
// parallel for loop is implemented using threads, all the usual techniques for
// ensuring thread safety can be used.
// ensuring thread safety can be used.
int sum = 0;
int sum = 0;
mutex m;
dlib::
mutex m;
vect.assign(10, 2);
vect.assign(10, 2);
parallel_for(num_threads, 0, vect.size(), [&](long i){
parallel_for(num_threads, 0, vect.size(), [&](long i){
// The sleep statements still execute in parallel.
// The sleep statements still execute in parallel.
...
@@ -194,7 +194,7 @@ struct function_object_sum
...
@@ -194,7 +194,7 @@ struct function_object_sum
const
std
::
vector
<
int
>&
vect
;
const
std
::
vector
<
int
>&
vect
;
int
&
sum
;
int
&
sum
;
mutex
m
;
dlib
::
mutex
m
;
void
operator
()
(
long
i
)
const
void
operator
()
(
long
i
)
const
{
{
...
...
examples/threads_ex.cpp
View file @
f4f39597
...
@@ -23,7 +23,7 @@ using namespace std;
...
@@ -23,7 +23,7 @@ using namespace std;
using
namespace
dlib
;
using
namespace
dlib
;
int
thread_count
=
10
;
int
thread_count
=
10
;
mutex
count_mutex
;
// This is a mutex we will use to guard the thread_count variable. Note that the mutex doesn't know
dlib
::
mutex
count_mutex
;
// This is a mutex we will use to guard the thread_count variable. Note that the mutex doesn't know
// anything about the thread_count variable. Only our usage of a mutex determines what it guards.
// anything about the thread_count variable. Only our usage of a mutex determines what it guards.
// In this case we are going to make sure this mutex is always locked before we touch the
// In this case we are going to make sure this mutex is always locked before we touch the
// thread_count variable.
// thread_count variable.
...
...
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