[polari/join-room-list: 1/2] serverRoomManager: Limit time spend in idle handler
- From: Gitlab System User <gitlab src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari/join-room-list: 1/2] serverRoomManager: Limit time spend in idle handler
- Date: Sat, 21 Oct 2017 17:40:46 +0000 (UTC)
commit c19e57c33dc36010111cbd2618fe3eb08e85ea3a
Author: Florian Müllner <fmuellner gnome org>
Date: Sat Oct 21 18:50:56 2017 +0200
serverRoomManager: Limit time spend in idle handler
The number of available rooms can be fairly large (*cough* Freenode
*cough*), so we currently insert rooms in chunks of 100 to make sure
that we don't block the mainloop while loading the list. We still suffer
from significant slow-down though, and Bastien Nocera pointed out that
instead of inserting a fixed number of rows, we should limit the time
spent in the idle handler to make sure that each frame still has enough
cycles for drawing.
Fixes https://gitlab.gnome.org/GNOME/polari/issues/13
src/serverRoomManager.js | 26 +++++++++++++++-----------
1 file changed, 15 insertions(+), 11 deletions(-)
---
diff --git a/src/serverRoomManager.js b/src/serverRoomManager.js
index 78004f3..fad05bd 100644
--- a/src/serverRoomManager.js
+++ b/src/serverRoomManager.js
@@ -12,7 +12,7 @@ const RoomManager = imports.roomManager;
const Signals = imports.signals;
const Utils = imports.utils;
-const LIST_CHUNK_SIZE = 100;
+const MS_PER_IDLE = 10;
let _singleton = null;
@@ -319,16 +319,24 @@ var ServerRoomList = new Lang.Class({
this._idleId = Mainloop.idle_add(() => {
let customName = this._store.get_value(this._customRoomItem,
RoomListColumn.NAME);
- this._pendingInfos.splice(0, LIST_CHUNK_SIZE).forEach(roomInfo => {
- let store = this._store;
+ let store = this._store;
+ let startTime = GLib.get_monotonic_time();
+ do {
+ let roomInfo = this._pendingInfos.shift();
+
+ if (roomInfo == undefined) {
+ this._idleId = 0;
+ this._checkSpinner();
+ return GLib.SOURCE_REMOVE;
+ }
let name = roomInfo.get_name();
if (name[0] == '#')
name = name.substr(1, name.length);
if (_strBaseEqual(name, customName))
- this._store.set_value(this._customRoomItem,
- RoomListColumn.NAME, customName = '');
+ store.set_value(this._customRoomItem,
+ RoomListColumn.NAME, customName = '');
let room = roomManager.lookupRoomByName(roomInfo.get_name(), this._account);
let sensitive = room == null;
@@ -342,13 +350,9 @@ var ServerRoomList = new Lang.Class({
RoomListColumn.SENSITIVE],
[checked, name, count, sensitive]);
store.move_before(iter, this._customRoomItem);
- });
- if (this._pendingInfos.length)
- return GLib.SOURCE_CONTINUE;
+ } while (GLib.get_monotonic_time() - startTime < 1000 * MS_PER_IDLE);
- this._idleId = 0;
- this._checkSpinner();
- return GLib.SOURCE_REMOVE;
+ return GLib.SOURCE_CONTINUE;
});
},
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]