make shmem swappable by ref and ptr

This commit is contained in:
Dennis Luxen 2013-10-08 15:26:19 +02:00
parent 843348338a
commit 5afed2d396

View File

@ -108,12 +108,32 @@ public:
} }
} }
void Swap(SharedMemory & other) {
SimpleLogger().Write() << "prev: " << shm.get_shmid();
shm.swap(other.shm);
region.swap(other.region);
boost::interprocess::xsi_key temp_key = other.key;
other.key = key;
key = temp_key;
SimpleLogger().Write() << "after: " << shm.get_shmid();
}
void Swap(SharedMemory * other) {
SimpleLogger().Write() << "prev: " << shm.get_shmid();
shm.swap(other->shm);
region.swap(other->region);
boost::interprocess::xsi_key temp_key = other->key;
other->key = key;
key = temp_key;
SimpleLogger().Write() << "after: " << shm.get_shmid();
}
template<typename IdentifierT > template<typename IdentifierT >
static bool RegionExists( static bool RegionExists(
const boost::filesystem::path & lock_file,
const IdentifierT id const IdentifierT id
) { ) {
boost::interprocess::xsi_key key( lock_file.string().c_str(), id ); OSRMLockFile lock_file;
boost::interprocess::xsi_key key( lock_file().string().c_str(), id );
return RegionExists(key); return RegionExists(key);
} }