class SyncSlot
{
public:
+ SyncSlot() :
+ isNewDirectory(false),
+ busy(false)
+ {}
+
WaitingSyncItem currentItem;
bool isNewDirectory;
std::queue<WaitingSyncItem> queue;
std::auto_ptr<SVNRepository> repository;
SGTimeStamp stamp;
+ bool busy; ///< is the slot working or idle
};
static const int SYNC_SLOT_TILES = 0; ///< Terrain and Objects sync
}
} catch (sg_exception& e) {
fail(next);
+ _busy = false;
return;
}
updated(next, isNewDirectory);
+ _busy = false;
}
void SGTerraSync::SvnThread::updateSyncSlot(SyncSlot &slot)
}
// whatever happened, we're done with this repository instance
+ slot.busy = false;
slot.repository.reset();
}
slot.repository->update();
slot.stamp.stamp();
+ slot.busy = true;
SG_LOG(SG_IO, SG_DEBUG, "sync of " << slot.repository->baseUrl() << " started");
}
}
_syncSlots[slot].queue.push(next);
}
+ bool anySlotBusy = false;
// update each sync slot in turn
for (unsigned int slot=0; slot < NUM_SYNC_SLOTS; ++slot) {
updateSyncSlot(_syncSlots[slot]);
+ anySlotBusy |= _syncSlots[slot].busy;
}
+
+ _busy = anySlotBusy;
} // of thread running loop
}
_consecutive_errors++;
_fail_count++;
_completedTiles[ failedItem._dir ] = now + UpdateInterval::FailedAttempt;
- _busy = false;
}
void SGTerraSync::SvnThread::updated(const WaitingSyncItem& item, bool isNewDirectory)
_completedTiles[ item._dir ] = now + UpdateInterval::SuccessfulAttempt;
writeCompletedTilesPersistentCache();
- _busy = false;
}
void SGTerraSync::SvnThread::initCompletedTilesPersistentCache()
last_lat(NOWHERE),
last_lon(NOWHERE),
_terraRoot(root->getNode("/sim/terrasync",true)),
+ _bound(false),
+ _inited(false),
_refreshCb(NULL),
_userCbData(NULL)
{
void SGTerraSync::init()
{
+ if (_inited) {
+ return;
+ }
+
+ _inited = true;
_refreshDisplay = _terraRoot->getNode("refresh-display",true);
_terraRoot->setBoolValue("built-in-svn-available",svn_built_in_available);
reinit();
// do not reinit when enabled and we're already up and running
if ((_terraRoot->getBoolValue("enabled",false))&&
(_svnThread->_active && _svnThread->_running))
+ {
return;
-
+ }
+
_svnThread->stop();
if (_terraRoot->getBoolValue("enabled",false))
void SGTerraSync::bind()
{
+ if (_bound) {
+ return;
+ }
+
+ _bound = true;
_tiedProperties.Tie( _terraRoot->getNode("busy", true), (bool*) &_svnThread->_busy );
_tiedProperties.Tie( _terraRoot->getNode("active", true), (bool*) &_svnThread->_active );
_tiedProperties.Tie( _terraRoot->getNode("update-count", true), (int*) &_svnThread->_success_count );
{
_svnThread->stop();
_tiedProperties.Untie();
+ _bound = false;
+ _inited = false;
}
void SGTerraSync::update(double)
SGTerraSync(SGPropertyNode_ptr root);
virtual ~SGTerraSync();
- virtual void init();
+
+ virtual void init();
virtual void reinit();
virtual void bind();
virtual void unbind();
SGPropertyNode_ptr _stalledNode;
SGPropertyNode_ptr _cacheHits;
+ // we manually bind+init TerraSync during early startup
+ // to get better overlap of slow operations (Shared Models sync
+ // and nav-cache rebuild). As a result we need to track the bind/init
+ // state explicitly to avoid duplicate calls.
+ bool _bound, _inited;
+
SGTerraSyncCallback _refreshCb;
void* _userCbData;
simgear::TiedPropertyList _tiedProperties;