Remove indirection

This commit is contained in:
John Firebaugh
2015-06-04 19:07:48 -07:00
parent 217c376291
commit 875ef979be
4 changed files with 17 additions and 68 deletions

View File

@@ -34,8 +34,6 @@ VectorTileData::VectorTileData(const TileID& id_,
}
VectorTileData::~VectorTileData() {
// Cancel in most derived class destructor so that worker tasks are joined before
// any member data goes away.
cancel();
}
@@ -52,7 +50,8 @@ void VectorTileData::request(Worker&,
if (res.status != Response::Successful) {
std::stringstream message;
message << "Failed to load [" << url << "]: " << res.message;
setError(message.str());
error = message.str();
state = State::obsolete;
callback();
return;
}
@@ -65,7 +64,7 @@ void VectorTileData::request(Worker&,
}
bool VectorTileData::reparse(Worker&, std::function<void()> callback) {
if (!mayStartParsing()) {
if (parsing.test_and_set(std::memory_order_acquire)) {
return false;
}
@@ -88,12 +87,13 @@ bool VectorTileData::reparse(Worker&, std::function<void()> callback) {
if (getState() == TileData::State::obsolete) {
return;
} else if (result.is<State>()) {
setState(result.get<State>());
state = result.get<State>();
} else {
setError(result.get<std::string>());
error = result.get<std::string>();
state = State::obsolete;
}
endParsing();
parsing.clear(std::memory_order_release);
}, callback);
return true;
@@ -111,16 +111,6 @@ size_t VectorTileData::countBuckets() const {
return workerData.countBuckets();
}
void VectorTileData::setState(const State& state_) {
assert(!isImmutable());
state = state_;
if (isImmutable()) {
workerData.collision->reset(0, 0);
}
}
void VectorTileData::redoPlacement() {
redoPlacement(lastAngle, lastCollisionDebug);
}
@@ -162,16 +152,3 @@ void VectorTileData::cancel() {
}
workRequest.reset();
}
bool VectorTileData::mayStartParsing() {
return !parsing.test_and_set(std::memory_order_acquire);
}
void VectorTileData::endParsing() {
parsing.clear(std::memory_order_release);
}
void VectorTileData::setError(const std::string& message) {
error = message;
setState(State::obsolete);
}