D
devdude
Hi,
I have the need to take a snapshot of a hash_map during execution
(actually transform it to a vector). This map is a shared resource
and therefore must be locked prior to any read/write operations thus I
need to minimize the amount of time the map resource is locked.
The map is defined as type <string, boost::shared_ptr<myobject>>. My
algorithm is as such:
void SnapShotToVector( vector< pair< string,
boost::shared_ptr<myobject> >& vec )
{
lockResource(this->map);
vec.resize( map.size() );
copy(this->map.begin(), this->map.end(),list.begin());
unlockResource(this->map);
}
For about 3M elements w/in the map, I'm noticing that the resize op
takes about 150ms and the copy takes ~850ms. Is there any way to do
better? I suppose the total time doesn' t matter as it's the time the
resource is actually locked is the primary concern.
TIA
I have the need to take a snapshot of a hash_map during execution
(actually transform it to a vector). This map is a shared resource
and therefore must be locked prior to any read/write operations thus I
need to minimize the amount of time the map resource is locked.
The map is defined as type <string, boost::shared_ptr<myobject>>. My
algorithm is as such:
void SnapShotToVector( vector< pair< string,
boost::shared_ptr<myobject> >& vec )
{
lockResource(this->map);
vec.resize( map.size() );
copy(this->map.begin(), this->map.end(),list.begin());
unlockResource(this->map);
}
For about 3M elements w/in the map, I'm noticing that the resize op
takes about 150ms and the copy takes ~850ms. Is there any way to do
better? I suppose the total time doesn' t matter as it's the time the
resource is actually locked is the primary concern.
TIA