Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
David Cazier
CGoGN
Commits
5b821f0b
Commit
5b821f0b
authored
Aug 27, 2012
by
Sylvain Thery
Browse files
Protect attribute register/unregister with mutex
parent
3b81dd69
Changes
3
Hide whitespace changes
Inline
Side-by-side
Apps/Tuto/tuto_mt.cpp
View file @
5b821f0b
...
...
@@ -176,7 +176,6 @@ public:
{
m_positions2
[
i
]
=
1.1
f
*
m_positions
[
i
];
}
// no need to duplicate here functor can be shared (no data), call foreach with true parameter
};
...
...
@@ -283,7 +282,7 @@ void MyQT::threadStorage()
}
CGoGNout
<<
"using "
<<
nbthreads
<<
" threads"
<<
CGoGNendl
;
Algo
::
Parallel
::
foreach_cell
<
PFP
::
MAP
,
EDGE
>
(
myMap
,
functs
,
nbthreads
);
Algo
::
Parallel
::
foreach_cell
<
PFP
::
MAP
,
EDGE
>
(
myMap
,
functs
);
//compute average length from each thread result and delete functors
double
average
=
0
;
...
...
include/Topology/generic/attributeHandler.hpp
View file @
5b821f0b
...
...
@@ -28,6 +28,7 @@ namespace CGoGN
template
<
typename
T
,
unsigned
int
ORBIT
>
inline
void
AttributeHandler
<
T
,
ORBIT
>::
registerInMap
()
{
boost
::
mutex
::
scoped_lock
lockAH
(
m_map
->
attributeHandlersMutex
);
m_map
->
attributeHandlers
.
insert
(
std
::
pair
<
AttributeMultiVectorGen
*
,
AttributeHandlerGen
*>
(
m_attrib
,
this
))
;
}
...
...
@@ -35,6 +36,8 @@ template <typename T, unsigned int ORBIT>
inline
void
AttributeHandler
<
T
,
ORBIT
>::
unregisterFromMap
()
{
typedef
std
::
multimap
<
AttributeMultiVectorGen
*
,
AttributeHandlerGen
*>::
iterator
IT
;
boost
::
mutex
::
scoped_lock
lockAH
(
m_map
->
attributeHandlersMutex
);
std
::
pair
<
IT
,
IT
>
bounds
=
m_map
->
attributeHandlers
.
equal_range
(
m_attrib
)
;
for
(
IT
i
=
bounds
.
first
;
i
!=
bounds
.
second
;
++
i
)
{
...
...
include/Topology/generic/genericmap.h
View file @
5b821f0b
...
...
@@ -33,6 +33,8 @@
#include
<list>
#include
<vector>
#include
<map>
#include
<boost/thread/mutex.hpp>
#include
"Container/attributeContainer.h"
...
...
@@ -113,6 +115,8 @@ protected:
* Store links to created AttributeHandlers, DartMarkers and CellMarkers
*/
std
::
multimap
<
AttributeMultiVectorGen
*
,
AttributeHandlerGen
*>
attributeHandlers
;
// TODO think of MT (AttributeHandler creation & release are not thread safe!
boost
::
mutex
attributeHandlersMutex
;
std
::
vector
<
DartMarkerGen
*>
dartMarkers
[
NB_THREAD
]
;
std
::
vector
<
CellMarkerGen
*>
cellMarkers
[
NB_THREAD
]
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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