Windows Overlay: Use FLUSHNOW everywhere to speed up updates

This commit is contained in:
Daniel Molkentin 2014-11-03 20:45:38 +01:00
Родитель af68cb6029
Коммит c34c8ff358
1 изменённых файлов: 15 добавлений и 12 удалений

Просмотреть файл

@ -16,6 +16,8 @@
#include "RemotePathChecker.h" #include "RemotePathChecker.h"
#include "StringUtil.h" #include "StringUtil.h"
#include <shlobj.h>
#include <algorithm> #include <algorithm>
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
@ -77,7 +79,7 @@ void RemotePathChecker::workerThreadLoop()
{ std::unique_lock<std::mutex> lock(_mutex); { std::unique_lock<std::mutex> lock(_mutex);
_watchedDirectories.push_back(responsePath); _watchedDirectories.push_back(responsePath);
} }
SHChangeNotify(SHCNE_UPDATEDIR, SHCNF_PATH, responsePath.data(), NULL); SHChangeNotify(SHCNE_UPDATEDIR, SHCNF_PATH | SHCNF_FLUSHNOWAIT, responsePath.data(), NULL);
} else if (StringUtil::begins_with(response, wstring(L"UNREGISTER_PATH:"))) { } else if (StringUtil::begins_with(response, wstring(L"UNREGISTER_PATH:"))) {
wstring responsePath = response.substr(16); // length of UNREGISTER_PATH: wstring responsePath = response.substr(16); // length of UNREGISTER_PATH:
@ -95,7 +97,7 @@ void RemotePathChecker::workerThreadLoop()
} }
} }
} }
SHChangeNotify(SHCNE_UPDATEDIR, SHCNF_PATH, responsePath.data(), NULL); SHChangeNotify(SHCNE_UPDATEDIR, SHCNF_PATH | SHCNF_FLUSHNOWAIT, responsePath.data(), NULL);
} else if (StringUtil::begins_with(response, wstring(L"STATUS:")) || } else if (StringUtil::begins_with(response, wstring(L"STATUS:")) ||
StringUtil::begins_with(response, wstring(L"BROADCAST:"))) { StringUtil::begins_with(response, wstring(L"BROADCAST:"))) {
@ -123,15 +125,16 @@ void RemotePathChecker::workerThreadLoop()
SHChangeNotify(SHCNE_UPDATEITEM, SHCNF_PATH | SHCNF_FLUSHNOWAIT, responsePath.data(), NULL); SHChangeNotify(SHCNE_UPDATEITEM, SHCNF_PATH | SHCNF_FLUSHNOWAIT, responsePath.data(), NULL);
} }
} }
} else if (StringUtil::begins_with(response, wstring(L"UPDATE_VIEW"))) { else if (StringUtil::begins_with(response, wstring(L"UPDATE_VIEW"))) {
std::unique_lock<std::mutex> lock(_mutex); std::unique_lock<std::mutex> lock(_mutex);
// Request a status for all the items in the cache. // Request a status for all the items in the cache.
for (auto it = _cache.begin(); it != _cache.end() ; ++it ) { for (auto it = _cache.begin(); it != _cache.end(); ++it) {
if (!socket.SendMsg(wstring(L"RETRIEVE_FILE_STATUS:" + it->first + L'\n').data())) { if (!socket.SendMsg(wstring(L"RETRIEVE_FILE_STATUS:" + it->first + L'\n').data())) {
break; break;
} }
} }
} }
}
if (socket.Event() == INVALID_HANDLE_VALUE) { if (socket.Event() == INVALID_HANDLE_VALUE) {
std::unique_lock<std::mutex> lock(_mutex); std::unique_lock<std::mutex> lock(_mutex);