Skip to content

Commit

Permalink
KitQueue - re-spin poll loop when we have tiles to render.
Browse files Browse the repository at this point in the history
Prepares us for having tiles that need rendering left over from
a drainQueue and not necessarily having another queue item to
trigger fast iteration of the poll.

Change-Id: Id51441070dfb883a5964308d54880d46a3210087
Signed-off-by: Michael Meeks <[email protected]>
  • Loading branch information
mmeeks committed Dec 7, 2024
1 parent a4d480a commit 3db8409
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
3 changes: 1 addition & 2 deletions kit/Kit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2446,8 +2446,7 @@ void Document::drainQueue()
}
}

if (processInputEnabled() && !isLoadOngoing() &&
!isBackgroundSaveProcess() && _queue->getTileQueueSize() > 0)
if (canRenderTiles())
{
std::vector<TileCombined> tileRequests = _queue->popWholeTileQueue();

Expand Down
10 changes: 9 additions & 1 deletion kit/Kit.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,14 +336,22 @@ class Document final : public std::enable_shared_from_this<Document>
/// A new message from wsd for the queue
void queueMessage(const std::string &msg) { _queue->put(msg); }
bool hasQueueItems() const { return _queue && !_queue->isEmpty(); }
bool canRenderTiles() const {
return processInputEnabled() && !isLoadOngoing() &&
!isBackgroundSaveProcess() && _queue &&
_queue->getTileQueueSize() > 0;
}
bool hasCallbacks() const { return _queue && _queue->callbackSize() > 0; }

/// Should we get through the SocketPoll fast to process queus ?
bool needsQuickPoll() const
{
if (hasCallbacks())
return true;
if (hasQueueItems() && processInputEnabled())
// not processing input messages or tile renders
if (!processInputEnabled())
return false;
if (hasQueueItems() || canRenderTiles())
return true;
return false;
}
Expand Down
6 changes: 3 additions & 3 deletions kit/KitQueue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,13 +191,13 @@ class KitQueue
int priority(const TileDesc &desc);

private:
/// The incoming underlying queue
/// Queue of incoming messages from coolwsd
std::vector<Payload> _queue;

/// Incoming tile request queue
/// Queue of incoming tile requests from coolwsd
std::vector<TileDesc> _tileQueue;

/// Outgoing queued callbacks
/// Queue of callbacks from Kit to send out to coolwsd
std::vector<Callback> _callbacks;

std::map<int, CursorPosition> _cursorPositions;
Expand Down

0 comments on commit 3db8409

Please sign in to comment.