Changed: Allow waiting for database status update.

--HG--
branch : build_pipeline_v3
hg/feature/build_pipeline_v3
kaetemi 13 years ago
parent b2d9a2fa3d
commit 5c37f2cc1b

@ -381,10 +381,10 @@ void CDatabaseStatus::updateDatabaseStatus(const CCallback<void> &callback)
{
std::vector<std::string> paths;
paths.push_back(g_DatabaseDirectory);
updateDatabaseStatus(callback, paths, true);
updateDatabaseStatus(callback, paths, false, true);
}
void CDatabaseStatus::updateDatabaseStatus(const CCallback<void> &callback, const std::vector<std::string> &paths, bool recurse)
void CDatabaseStatus::updateDatabaseStatus(const CCallback<void> &callback, const std::vector<std::string> &paths, bool wait, bool recurse)
{
CDatabaseStatusUpdater *updater = new CDatabaseStatusUpdater();
updater->Callback = callback;
@ -411,6 +411,16 @@ void CDatabaseStatus::updateDatabaseStatus(const CCallback<void> &callback, cons
updater->Mutex.leave();
if (done) updater->doneRemove();
if (wait)
{
// UGLY_CODE ->
while (!updater->CallbackCalled)
{
nlSleep(10);
}
// <- UGLY_CODE
}
}
// ******************************************************************

@ -106,10 +106,10 @@ public:
bool getFileStatus(CFileStatus &fileStatus, const std::string &filePath) const;
/// Updates the file status asynchronously. The new file status is broadcast to clients and slaves afterwards. Warning: If g_IsExiting during callback then update likely did not happen.
NLMISC::IRunnable *updateFileStatus(const TFileStatusCallback &callback, const std::string &filePath);
/// Runs an update of the complete {{DatabaseDirectory}} status. Warning: If g_IsExiting during callback then update is incomplete. Callback is always called when done (or failed).
/// Runs an update of the complete {{DatabaseDirectory}} status asynchronously. Warning: If g_IsExiting during callback then update is incomplete. Callback is always called when done (or failed).
void updateDatabaseStatus(const CCallback<void> &callback);
/// Runs an update of the file status of given paths. Warning: If g_IsExiting during callback then update is incomplete. Callback is always called when done (or failed). Do NOT use recurse, please. Recurse directories beforehand. Paths may contain db and pl macros.
void updateDatabaseStatus(const CCallback<void> &callback, const std::vector<std::string> &paths, bool recurse = false);
/// Runs an update of the file status of given paths asynchronously. Warning: If g_IsExiting during callback then update is incomplete. Callback is always called when done (or failed). Do NOT use the wait parameter. Do NOT use recurse, please. Recurse directories beforehand. Paths may contain db and pl macros.
void updateDatabaseStatus(const CCallback<void> &callback, const std::vector<std::string> &paths, bool wait = false, bool recurse = false);
void getFileErrors(CFileErrors &fileErrors, const std::string &filePath, uint32 newerThan = 0) const;
void addFileError(const std::string &filePath, const CFileError &fileError);

Loading…
Cancel
Save