[Libreoffice-commits] online.git: 2 commits - loolwsd/MessageQueue.cpp loolwsd/MessageQueue.hpp
Jan Holesovsky
kendy at collabora.com
Mon Sep 26 08:56:04 UTC 2016
loolwsd/MessageQueue.cpp | 62 ++++++++++++++++++++++++++++-------------------
loolwsd/MessageQueue.hpp | 2 +
2 files changed, 39 insertions(+), 25 deletions(-)
New commits:
commit fb0e041232c9e8c345600eede619a0ca9a947741
Author: Jan Holesovsky <kendy at collabora.com>
Date: Mon Sep 26 10:35:20 2016 +0200
De-duplicate the tiles resulting from the tilecombine split.
Change-Id: I836915c06685f94b01a4d3af66092b9f45e82217
diff --git a/loolwsd/MessageQueue.cpp b/loolwsd/MessageQueue.cpp
index 95aa9ff..82dce6a 100644
--- a/loolwsd/MessageQueue.cpp
+++ b/loolwsd/MessageQueue.cpp
@@ -64,7 +64,7 @@ bool MessageQueue::wait_impl() const
MessageQueue::Payload MessageQueue::get_impl()
{
- auto result = _queue.front();
+ Payload result = _queue.front();
_queue.pop_front();
return result;
}
@@ -108,39 +108,51 @@ void TileQueue::put_impl(const Payload& value)
}
else if (msg.compare(0, 11, "tilecombine") == 0)
{
- // Breakup tilecombine and deduplicate.
+ // Breakup tilecombine and deduplicate (we are re-combining the tiles
+ // in the get_impl() again)
const auto tileCombined = TileCombined::parse(msg);
for (auto& tile : tileCombined.getTiles())
{
- const auto newMsg = tile.serialize("tile");
- _queue.push_back(Payload(newMsg.data(), newMsg.data() + newMsg.size()));
+ const std::string newMsg = tile.serialize("tile");
+
+ removeDuplicate(newMsg);
+
+ MessageQueue::put_impl(Payload(newMsg.data(), newMsg.data() + newMsg.size()));
}
+ return;
}
+ else if (msg.compare(0, 4, "tile") == 0)
+ {
+ removeDuplicate(msg);
+
+ MessageQueue::put_impl(value);
+ return;
+ }
+
+ // TODO probably we could deduplacite the invalidation callbacks (later
+ // one wins) the same way as we do for the tiles - to be tested.
+
+ MessageQueue::put_impl(value);
+}
- if (!_queue.empty())
+void TileQueue::removeDuplicate(const std::string& tileMsg)
+{
+ assert(tileMsg.compare(0, 4, "tile") == 0);
+
+ const std::string newMsg = tileMsg.substr(0, tileMsg.find(" ver"));
+
+ for (size_t i = 0; i < _queue.size(); ++i)
{
- // TODO probably we could do the same with the invalidation callbacks
- // (later one wins).
- if (msg.compare(0, 4, "tile") == 0)
+ auto& it = _queue[i];
+ const std::string old(it.data(), it.size());
+ const std::string oldMsg = old.substr(0, old.find(" ver"));
+ if (newMsg == oldMsg)
{
- const auto newMsg = msg.substr(0, msg.find(" ver"));
-
- for (size_t i = 0; i < _queue.size(); ++i)
- {
- auto& it = _queue[i];
- const std::string old(it.data(), it.size());
- const auto oldMsg = old.substr(0, old.find(" ver"));
- if (newMsg == oldMsg)
- {
- Log::debug() << "Remove duplicate message: " << old << " -> " << msg << Log::end;
- _queue.erase(_queue.begin() + i);
- break;
- }
- }
+ Log::debug() << "Remove duplicate message: " << old << " -> " << tileMsg << Log::end;
+ _queue.erase(_queue.begin() + i);
+ break;
}
}
-
- MessageQueue::put_impl(value);
}
bool TileQueue::priority(const std::string& tileMsg)
diff --git a/loolwsd/MessageQueue.hpp b/loolwsd/MessageQueue.hpp
index 0edbe2d..1dee715 100644
--- a/loolwsd/MessageQueue.hpp
+++ b/loolwsd/MessageQueue.hpp
@@ -125,6 +125,8 @@ protected:
virtual Payload get_impl() override;
private:
+ /// Search the queue for a duplicate tile and remove it (if present).
+ void removeDuplicate(const std::string& tileMsg);
/// Check if the given tile msg underlies a cursor.
bool priority(const std::string& tileMsg);
commit 137e677eb0d6af1996701b2bd1b27a6eb3822613
Author: Jan Holesovsky <kendy at collabora.com>
Date: Mon Sep 26 10:46:05 2016 +0200
Fix a typo that prevented tilecombines from being split.
Change-Id: Iceecfcff3b547485a94a0b9ac356d634505ccbb4
diff --git a/loolwsd/MessageQueue.cpp b/loolwsd/MessageQueue.cpp
index 830a162..95aa9ff 100644
--- a/loolwsd/MessageQueue.cpp
+++ b/loolwsd/MessageQueue.cpp
@@ -106,7 +106,7 @@ void TileQueue::put_impl(const Payload& value)
Log::trace() << "After canceltiles have " << _queue.size() << " in queue." << Log::end;
return;
}
- else if (msg.compare(0, 10, "tilecombine") == 0)
+ else if (msg.compare(0, 11, "tilecombine") == 0)
{
// Breakup tilecombine and deduplicate.
const auto tileCombined = TileCombined::parse(msg);
More information about the Libreoffice-commits
mailing list