Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F112621820
synchronizer_registry.cc
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, May 11, 16:50
Size
4 KB
Mime Type
text/x-c
Expires
Tue, May 13, 16:50 (20 h, 45 m)
Engine
blob
Format
Raw Data
Handle
26002313
Attached To
rAKA akantu
synchronizer_registry.cc
View Options
/**
* @file synchronizer_registry.cc
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
*
* @date creation: Thu Jun 16 2011
* @date last modification: Tue Nov 06 2012
*
* @brief Registry of synchronizers
*
* @section LICENSE
*
* Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "synchronizer_registry.hh"
/* -------------------------------------------------------------------------- */
__BEGIN_AKANTU__
/* -------------------------------------------------------------------------- */
SynchronizerRegistry
::
SynchronizerRegistry
(
DataAccessor
&
da
)
:
// nb_synchronization_tags(0),
data_accessor
(
da
)
{
AKANTU_DEBUG_IN
();
AKANTU_DEBUG_OUT
();
}
/* -------------------------------------------------------------------------- */
SynchronizerRegistry
::~
SynchronizerRegistry
()
{
AKANTU_DEBUG_IN
();
// for (Tag2Sync::iterator it = synchronizers.begin();
// it != synchronizers.end();
// ++it) {
// delete it->second;
// }
synchronizers
.
clear
();
AKANTU_DEBUG_OUT
();
}
/* -------------------------------------------------------------------------- */
void
SynchronizerRegistry
::
synchronize
(
SynchronizationTag
tag
)
{
AKANTU_DEBUG_IN
();
std
::
pair
<
Tag2Sync
::
iterator
,
Tag2Sync
::
iterator
>
range
=
synchronizers
.
equal_range
(
tag
);
for
(
Tag2Sync
::
iterator
it
=
range
.
first
;
it
!=
range
.
second
;
++
it
)
{
(
*
it
).
second
->
synchronize
(
data_accessor
,
tag
);
}
AKANTU_DEBUG_OUT
();
}
/* -------------------------------------------------------------------------- */
void
SynchronizerRegistry
::
asynchronousSynchronize
(
SynchronizationTag
tag
)
{
AKANTU_DEBUG_IN
();
std
::
pair
<
Tag2Sync
::
iterator
,
Tag2Sync
::
iterator
>
range
=
synchronizers
.
equal_range
(
tag
);
for
(
Tag2Sync
::
iterator
it
=
range
.
first
;
it
!=
range
.
second
;
++
it
)
{
(
*
it
).
second
->
asynchronousSynchronize
(
data_accessor
,
tag
);
}
AKANTU_DEBUG_OUT
();
}
/* -------------------------------------------------------------------------- */
void
SynchronizerRegistry
::
waitEndSynchronize
(
SynchronizationTag
tag
)
{
AKANTU_DEBUG_IN
();
std
::
pair
<
Tag2Sync
::
iterator
,
Tag2Sync
::
iterator
>
range
=
synchronizers
.
equal_range
(
tag
);
for
(
Tag2Sync
::
iterator
it
=
range
.
first
;
it
!=
range
.
second
;
++
it
)
{
(
*
it
).
second
->
waitEndSynchronize
(
data_accessor
,
tag
);
}
AKANTU_DEBUG_OUT
();
}
/* -------------------------------------------------------------------------- */
void
SynchronizerRegistry
::
registerSynchronizer
(
Synchronizer
&
synchronizer
,
SynchronizationTag
tag
)
{
AKANTU_DEBUG_IN
();
synchronizers
.
insert
(
std
::
pair
<
SynchronizationTag
,
Synchronizer
*>
(
tag
,
&
synchronizer
));
AKANTU_DEBUG_OUT
();
}
/* -------------------------------------------------------------------------- */
void
SynchronizerRegistry
::
printself
(
std
::
ostream
&
stream
,
int
indent
)
const
{
std
::
string
space
;
for
(
Int
i
=
0
;
i
<
indent
;
i
++
,
space
+=
AKANTU_INDENT
);
stream
<<
space
<<
"SynchronizerRegistry ["
<<
std
::
endl
;
Tag2Sync
::
const_iterator
it
;
for
(
it
=
synchronizers
.
begin
();
it
!=
synchronizers
.
end
();
it
++
)
{
stream
<<
space
<<
" + Synchronizers for tag "
<<
(
*
it
).
first
<<
" ["
<<
std
::
endl
;
(
*
it
).
second
->
printself
(
stream
,
indent
+
1
);
stream
<<
space
<<
" ]"
<<
std
::
endl
;
}
stream
<<
space
<<
"]"
<<
std
::
endl
;
}
__END_AKANTU__
Event Timeline
Log In to Comment